Former Mets pitcher Dwight Gooden during an interview in 2015.

Former Mets pitcher Dwight Gooden during an interview in 2015. Credit: Newsday/Alejandra Villa

Dwight Gooden can avoid jail time as part of a plea deal with Monmouth County, New Jersey, prosecutors following his arrest in June on suspected cocaine possession, a spokesman for the prosecutor’s office said Friday.

Gooden, 54, pled guilty in court Aug. 29 to a lesser charge of third-degree possession and was told he will not have to go to jail if he completes a drug rehabilitation program, spokesman Chris Swendeman said.

The former Mets and Yankees pitcher, who has struggled with substance abuse for three decades, said in a text message to Newsday on July 12 that he was “going away for a while to try and save my life” and “this is the worst I've ever been through all my struggles.”

In a statement Friday, Gooden’s Garden City-based attorney William Petrillo said: “Dwight is doing phenomenal and we are confident he will continue to do so. He is extremely grateful for the continued outpouring of love and support he has received from family, fans and friends, including many professional athletes.”

The prosecutor's office said Gooden will be sentenced Nov. 1. He had been arrested in the early morning hours on June 7 after he was found by Holmdel (N.J.) police to have “two, small green zip-lock style plastic baggies containing suspected cocaine.”

Gooden still faces a driving while intoxicated charge stemming from his arrest July 22 when Newark police officers noticed him driving his black 2012 Chrysler in the wrong direction on a one-way street.

He did not immediately return a message seeking comment on Friday.

Newsday LogoDON'T MISS THIS LIMITED-TIME OFFER1 5 months for only $1Save on Unlimited Digital Access