On-again, off-again couple Eminem and Kim Mathers agreed Monday not to criticize each other in public for the sake of their daughter.

The 34-year-old superstar rapper and his ex-wife agreed in a court hearing that insulting each other through the media could be harmful to 11-year-old Hailie.

Eminem filed a motion in Macomb County Circuit Court earlier this month that sought to prevent Mathers from making "derogatory, disparaging, inflammatory and otherwise negative comments" about him.

Click here for FOXNews.com's Music center.

Mathers, who has twice married and divorced the rapper, blasted Eminem in recent TV and radio interviews, including one on a Detroit radio station in which she said he was unfaithful and uncaring — and disparaged his sexual prowess.

She attended the hearing and a closed-door meeting beforehand in the chambers of Friend of the Court Referee David Elias. Eminem, whose real name is Marshall Bruce Mathers III, wasn't in court, but spoke by telephone in Elias' chambers.

The two sides agreed to the deal, and it was announced at the court hearing.

"We're happy the court was able to bring this matter to a just and equitable resolution," Eminem's lawyer, Harvey Hauer, said outside the courtroom.

Michael J. Smith, Mathers' attorney, said the decision was reached "for the full benefit of the child."

The couple married in 1999, divorced in 2001, remarried in January 2006 and separated three months later. Their second divorce was finalized in December.

Their daughter, Hailie, was born in 1996.

Eminem has won nine Grammy Awards, including best rap album for "The Slim Shady LP," "The Marshall Mathers LP" and "The Eminem Show." He won an Oscar for the song "Lose Yourself" from the hit 2002 film "8 Mile."