A Petaluma youth baseball coach who helped his team to the Little League World Series pleaded no contest Friday to a felony stalking charge in connection with a series of text messages he sent to his estranged wife.

In exchange for his plea, prosecutors will drop child endangerment charges against Trevor Tomei, 47, of Petaluma, and he will be released from jail into a 30-day residential drug treatment program.

Tomei will be allowed to have his stalking charge reduced to a misdemeanor upon successful completion of three years’ probation.

His lawyer said his behavior, in which he texted his wife repeatedly in violation of a restraining order, was caused by a drug problem. Tomei was arrested in October.

“He feels very remorseful about what happened,” attorney Evan Zelig said. “It’s certainly out of character for him.”

Tomei was one of three coaches to lead Petaluma National, an all-star team of 11- and 12-year-olds, in the 2012 Little League World Series in South Williamsport, Pa. The team finished in third place.

You can reach Staff Writer Paul Payne at 568-5312 or paul.payne@pressdemocrat.com. On Twitter @ppayne.