Actor is sentenced to community service and three years probation in incident involving ex-girlfriend Oksana Grigorieva.

Mel Gibson walked a gantlet of paparazzi and stood before a courtroom packed with reporters and wired with video cameras streaming online coverage Friday to agree formally to a plea deal in a domestic violence case that has dogged him for nearly a year.

The actor pleaded no contest to the charge of misdemeanor battery of his former girlfriend in a deal that allowed him to avoid jail time and, as his lawyer noted when news of the agreement broke, an "enormous media circus" sure to accompany a trial.

The appearance of a solemn, pale Gibson at the Airport Branch Courthouse came the same day as the Los Angeles County district attorney's office announced that it would not prosecute his ex-girlfriend, Russian musician Oksana Grigorieva, for attempted extortion connected to now infamous recordings she made of him in racist, profane rants.

The bitterness of that breakup, which has occupied the tabloids and a family court judge for 10 months, could be seen in the details of Gibson's plea deal, which allowed him to continue asserting his innocence in a Jan. 6, 2010, altercation at his Malibu mansion that Grigorieva said left her with two broken teeth and a black eye.

As Gibson watched silently, his lawyer took pains during the proceeding to distinguish his no contest plea from a guilty plea and to note that the actor was admitting no wrongdoing.

"The district attorney's office has agreed that resolving the matter does not require Mr. Gibson to say guilty," his attorney, Blair Berk, said. In criminal court, a no contest plea has the same effect as a guilty plea, but it protects the person from civil damage suits by victims.

Deputy Dist. Atty. Simone Shay said the agreement was struck to minimize "trauma and impact" on the victim and the couple's child, Lucia.

Los Angeles County Superior Court Judge Stephanie Sautner sentenced Gibson, 55, to three years probation and ordered him to stay away from Grigorieva, with whom he remains locked in an ugly court battle over custody and child support.

Gibson's lawyer said the actor would complete a requirement for a yearlong domestic violence counseling program with a therapist he began seeing in January. Gibson will complete 16 hours of community service with Mending Kids International, a Burbank-based medical charity connected to his estranged wife, Robyn, his attorney said.

Sautner warned him that violating any terms of the agreement could result in a year in jail and said of the protective order, "You are not to use violence or threaten anyone."

Gibson spoke only briefly and in answer to queries from the judge about his understanding of the deal.

"I have a good grasp of everything my attorney has discussed with me," Gibson said.

When the hearing concluded, Gibson, , his attorney and his publicist, accompanied by sheriff's deputies, swept by reporters and into an SUV without speaking.

Grigorieva went to authorities last summer, six months after the Malibu incident in which she said Gibson had punched her and threatened her with a gun as she held their daughter, who was then an infant. Subsequently, the recordings of an enraged Gibson surfaced on Radar Online. The tapes included Gibson telling Grigorieva that she "deserved" the assault.

Sheriff's detectives later opened a second investigation into allegations that Grigorieva had tried to extort as much as $26 million from Gibson with the tapes. In a one-page worksheet, Shay, the prosecutor, wrote, "There is insufficient evidence to prove beyond a reasonable doubt that the crime of attempted extortion was committed."