BALTIMORE — Olympic gold medal swimmer Michael Phelps avoided jail time on Friday when a judge placed him on probation for pleading guilty to a drunken driving charge for the second time in 10 years. The punishment came with a warning.

"You don't need a lecture from the court," Baltimore District Judge Nathan Braverman told Phelps. "If you haven't gotten the message by now, or forget the message, the only option is jail."

Probation allows the most decorated Olympian ever to focus on training for the 2016 Games in Rio De Janeiro, which would be his fifth. The 29-year-old came out of a year's retirement with his sights set on Rio, and the plea is not expected to have any ill effect on those plans.

The swimmer was contrite in court, with his attorney detailing his pursuit of sobriety since his arrest, including 45 days of inpatient treatment in Arizona. A letter from his doctor there was glowing, saying he was forthright and cooperative.

Phelps' attorney, Steve Allen, told the judge that Phelps had already made tremendous progress, and is continuing with therapy in Maryland and has enrolled in Alcoholics Anonymous.

"Mr. Phelps is a wonderful person," Allen said. "He's a gifted athlete, but he's also a person who gives back to the community. Mr. Phelps gets it: he gets what he did, he gets that he has a problem. He's had nothing but remorse for his mistake."

Documents show Phelps was stopped on Sept. 30 for speeding and crossing the double yellow line while driving in the Fort McHenry Tunnel. Police say Phelps registered a .14 percent on a blood-alcohol test. The legal limit is .08 percent in Maryland.

An officer said he pulled Phelps over for going 84 mph in a 45 mph zone.

The judge sentenced Phelps to a year in prison, but the sentence is suspended in favor of 18 months on probation.

The 18-time gold medalist will not be allowed to drink any alcohol while on probation. Phelps' license was suspended for 90 days after he was arrested, though Allen said that could be extended as a result of the guilty plea.

Phelps, who was surrounded by his mother, sisters and friends, including former Baltimore Ravens linebacker Ray Lewis, addressed the judge and acknowledged his poor judgment.

"I now have the tools to move past this. What I did was wrong, and I made a bad mistake. I'm looking forward to having a much brighter future than I had in the past," Phelps said.

After pleading guilty to his first drunken driving charge in 2004, Phelps was sentenced to probation and required to talk to high school students about alcohol awareness. Phelps pleaded guilty to the charges, but as a young first-time offender he avoided conviction.

"I recognize the seriousness of this mistake," he said at the time. "I've learned from this mistake and will continue learning from this mistake for the rest of my life."

Another embarrassment for Phelps came in 2009, when a British tabloid newspaper published a photo of him using a marijuana pipe at a party in South Carolina. Afterward, Phelps was suspended from USA swimming for three months and one of his major sponsors, Kellogg Co., dropped him.

Phelps has returned to training and a six-month suspension imposed by USA Swimming ends on March 6. That will allow him to swim the final three events on the U.S. Grand Prix schedule. Phelps might also seek to add some international meets to beef up his 2015 schedule, since he is also banned from swimming in next summer's world championships in Russia.

"We're looking at a lot of different options for competition," his coach, Bob Bowman, told The Associated Press in a recent interview. "We'll look at things in March and really go from there."

Phelps retired after the 2012 London Olympics but changed his mind a year later. Bowman said the swimmer was in much better shape, even after his DUI arrest and taking time off, than he was during his initial return to the pool.

Phelps won three golds and two silvers at one of the biggest meets of the 2014, the Pan Pacific Championships in August. He was named the male athlete of the year by USA Swimming.

As he walked down the steps of the Baltimore courthouse, Phelps said the past three months have been among the most difficult of his life.

"I'm finding out a lot about myself and for this day, I'm happy to be moving forward," Phelps said. "I'll continue to grow from this and continue on my path or recovery."