Southern California -- this just in

Mel Gibson appeared in the LAX Courthouse on Friday and pleaded no contest to a misdemeanor spousal battery charge, closing his high-profile domestic violence case involving his ex-girlfriend.

Gibson thanked the judge and the prosecutor as the hearing ended.

The judge sentenced Gibson to 36 months' probation and to complete a 52-week domestic violence counseling program and 16 hours of community service.

“He maintains his innocence,” his attorney Blair Berk told the judge. “He feels a plea is in the best interest of his children.”

He’s being served with a protective order Friday, which requires him to not harass or intimidate Oksana Grigorieva, his ex-girlfriend.

The actor-director's latest legal trouble began last year when Grigorieva, the mother of his daughter, accused him of threatening her with a gun and punching her at his Malibu home.

Secret recordings of Gibson engaging in a series of racist, profane rants were leaked to the celebrity website Radar Online. In the recordings, Gibson appeared to confirm Grigorieva's allegation of violence, telling her: "You … deserved it."