Former two-division UFC champion Conor McGregor today agreed to a plea deal that will keep him out of jail and allow him to resume his fighting career.

McGregor, 30, and his teammate Cian Cowley, 25, today pleaded guilty to disorderly conduct in Kings County Criminal Court in Brooklyn, N.Y.

Judge Raymond Rodriguez ordered McGregor to undergo five days of community service and one to three days of anger-management classes. McGregor also was ordered to pay restitution for the bus attack that left two UFC fighters injured.

Assistant District Attorney Janet Gleeson later told USA TODAY that McGregor already has paid for the damage.

McGregor, wearing a dark blue suit, responded “no, your honor” when judge Rodriguez judge asked if he had anything to say on his behalf.

A pair of felony counts of criminal mischief against McGregor were dropped as a condition of the plea. He was ordered not to go near three people affected by the attack, including UFC lightweight Michael Chiesa and onetime UFC flyweight title challenger Ray Borg, who were hit by shards of glass and forced to withdraw from scheduled bouts at UFC 223.

Cowley, meanwhile, was given three days community service and anger management classes.

Outside the courtroom after the hearing, McGregor made brief statement to news media members and a handful of fans gathered outside court before departing in a black SUV.

“I just want to say I’m thankful to the DA and the judge for allowing me to move forward,” he said. “I want to say to my friends, my family, my fans, thank you for the support.”

In a statement sent to USA TODAY, the Brooklyn District Attorney’s Office said: “This is a fair resolution that holds the defendant accountable, ensures restitution for the victims and requires the defendant to perform community service where he can reflect on his conduct and give back to society.”

McGregor, 30, turned himself into police and was arrested on multiple charges — including the two felonies —after he threw objects at a bus full of UFC 223 fighters at Barclays Center in April. The incident was caught on video and immediately went viral.

UFC President Dana White called the attack the “most disgusting thing that has ever happened in the history of the company” and put McGregor’s career on halt until the resolution of the case.

With no travel restrictions imposed by his plea, however, McGregor is expected to resume his octagon career in a title bout against current UFC lightweight champion Khabib Nurmagomedov, who was in the bus at the time of the attack and went on to capture the belt that the promotion stripped from McGregor.

At a scheduling hearing in June, McGregor’s attorneys indicated they were working on a plea deal with prosecutors. The UFC star also accepted responsibility for his role in the indicent.

“I regret my actions,” McGregor said. “I understand the seriousness of this matter and I am hopeful that it gets resolved soon.”

Far and away the UFC’s biggest draw, McGregor became the promotion’s first two-division champion in 2016 when he captured the lightweight title from Eddie Alvarez, adding to the featherweight title he already held.

When McGregor didn’t defend either belt, however, the promotion took action, first stripping him of the featherweight title. McGregor then pivoted toward a boxing match with Floyd Mayweather, which the UFC co-promoted in August 2017. The event was the second highest grossing domestic pay-per-view in history.

The UFC expected McGregor to return to the octagon after the boxing match. When he failed to commit to a date, the promotion moved to strip him of the lightweight title. McGregor reacted angrily at the announcement, which came just a few weeks prior to his rampage.

For more on the UFC’s upcoming schedule, check out the UFC Rumors section of the site.