Chris Brown pleaded guilty to assaulting Rihanna and the two were ordered to stay away from each other, in a deal that keeps the singer out of prison but requires him to clean up graffiti or roadside trash.

Download the new Independent Premium app Sharing the full story, not just the headlines

Brown's plea to a felony charge will subject him to substantial scrutiny by probation officials, and the judge's order rules out any short-term prospects for reconciliation with his pop diva girlfriend as well.

The guilty plea came before a preliminary hearing was scheduled to start. The hearing had been billed for weeks as a public face-off between the pair, with Rihanna set to testify against her one-time boyfriend.

Instead, Brown averted the potentially damaging meeting by entering a plea that will subject him to probation for the next five years as well as force him to perform six months of community service.

Mark Geragos, Brown's lawyer, said the plea represented the singer taking responsibility for his actions — which included beating, choking and biting Rihanna during a fight early Feb. 8, according to police.

After Brown left the courtroom, Rihanna entered and was addressed by Los Angeles Superior Court Judge Patricia Schnegg, who explained to the Barbados-born singer that she had issued a stay-away order.

Rihanna had not been seeking such an order, but the judge imposed one anyway. The order requires that Brown and Rihanna stay at least 50 yards (45 meters) from each other, except at industry events when the distance is reduced to 10 yards (nine meters).

The judge also told Rihanna it is not a one-way order — and that she, too, should not get any closer to Brown than the order allows.

"This is a kid who's never been in trouble before," Geragos said after the hearing. "He embraces this as a chance to get the message out that domestic violence will not be tolerated. He wants to get his life back on track."

Brown will be formally sentenced on 5 August.

Schnegg accepted Brown's plea, but expressed some concerns because Brown is not a California resident. She said Brown likely will be allowed to do his service in his home state of Virginia, but she did not want him to spend his time at churches or community centers.

Instead, Schnegg ordered Brown to get his hands dirty by doing work equivalent to what he would do in California — clean up grafitti or roadside trash.

She also said he'll have to return to California every three months and attend domestic violence counseling.

Sandi Gibbons, a spokeswoman for the Los Angeles County district attorney's office, said the terms were in line with what others receive when they are charged with similar crimes and have no prior criminal history.

Brown spoke softly throughout the hearing as he waived his rights and told the judge he understood the gravity of his plea.

"I think it's commendable you took responsibility for your conduct," Schnegg told Brown.

She said she hoped "the terms and conditions of your probation will have some meaning."

Rihanna spoke briefly, too, telling Schnegg she understood the terms of the stay-away order and that after Brown's sentencing she might ask for its terms to be loosened.

Rihanna, 21, recorded one of 2007's most popular songs with "Umbrella" and has numerous other hits. Her looks have made her a cover girl for magazines, as well as a pitchwoman for Cover Girl cosmetics.

The deal provides an end to a case that sparked intense media interest and severe backlash against Brown. Sponsors and radio stations dropped him, and the singer had to cancel several high-profile appearances, including a performance at the Grammys.

The singer once known for his squeaky-clean image now has a substantial blemish on his record. Brown, 20, rose to fame after the 2005 hit "Run It!" He was nominated for a Grammy for "No Air" with Jordin Sparks and named Billboard's top artist in 2008.

Intense media coverage led to Rihanna being identified as Brown's victim mere hours after the attack. Within weeks, a photo of the singer and model's bruised and battered face was posted on celebrity gossip site TMZ.

The posting sparked an investigation by the Los Angeles Police Department into whether one of its own officers leaked the photo to the Web site. Brown's attorney unsuccessfully argued the leak hurt Brown and that he should be granted access to LAPD's investigative files.

Brown recently proclaimed in a video posted to YouTube that he was "not a monster."

Even after Monday's hearing, lawyers for Brown and Rihanna refused to discuss the status of the pair's relationship.

Brown was arrested hours after police say he hit and threatened Rihanna after leaving a pre-Grammy party in Los Angeles. He was later charged with felony assault likely to produce great bodily harm and making criminal threats.

If convicted, the singer faced sentences ranging up to nearly five years in prison.

After an inital retreat from the public eye, both musicians have gradually appeared in public more frequently. Lately they have been photographed separately, including at a National Basketball Association finals game between the Orlando Magic and Los Angeles Lakers.

But neither has been able to shake the stigma of the court case and return to their usual jobs — making music.

The logistics of Brown's sentence may make it difficult to get back to his job.

"It amounts to a very sweaty house arrest," said Loyola University Law School Professor Stan Goldman, who was in the courtroom. "You have to have the discipline to show up several times a week. How many times will this interfere with a record date or an appearance?"