LOS ANGELES, California (CNN) -- A plea deal has been reached in the assault case against singer Chris Brown, defense attorney Mark Geragos said in a hearing Monday.
Chris Brown, at court Monday, will serve five years probation and must do jail time or community service.
Brown, 20, faced charges of assaulting his pop star girlfriend, Rihanna, following a row earlier this year.
Under terms of the agreement, Brown will serve five years of probation and must serve 180 days in jail or the equivalent -- about 1,400 hours -- in "labor-oriented service," said Sandi Gibbons, spokeswoman for the Los Angeles County District Attorney's office. He must also undergo a year-long domestic-violence counseling class, she said.
Brown's sentence is comparable to other felony sentences when the defendant has no previous record, she said.
"This is not an easy sentence," Gibbons said. He must check in with a probation officer every three months.
Brown had previously pleaded not guilty to felony counts of assault and making criminal threats in connection with an attack on Rihanna.
But under the plea deal, he pleaded guilty to one count of assault with the intent of doing great bodily injury in connection with the argument inside a rented Lamborghini on a Hollywood street in February. See a timeline of events in this case »
Rihanna, whose real name is Robyn Rihanna Fenty, made a brief appearance at the hearing -- after Brown had left the courtroom -- to hear Los Angeles Criminal Court Judge Patricia Schnegg discuss the issuance of a "stay away" order requiring him to stay 100 yards from her. Through her attorney, Rihanna had requested that such an order not be issued.
But Schnegg refused that request, saying she would issue such an order but would revise it to 50 yards -- 10 yards if the two are at the same "industry event" together.
Schnegg told Rihanna, who was wearing a black dress with white pearls around her neck, that she would consider lifting the order after Brown completes his domestic violence counseling but advised Rihanna not to contact Brown. Asked whether she understood, Rihanna said she did before leaving the courtroom via a back door.
Rihanna's attorney, Donald Etra, said Rihanna made the request because she felt that a protective order in place, requiring that Brown not annoy or harass her, was sufficient.
Schnegg said Brown could apply to have his supervised probation transferred to Virginia, where he maintains his legal residence. He also can complete his community service there, she said, but it would have to meet the court's standards.
"I want Mr. Brown treated as any other defendant who comes to this court," Schnegg said. She noted, however, that he has no prior criminal record.
Gibbons, of the district attorney's office, explained that the judge wants Brown to work -- remove graffiti, for instance -- as part of his service.
"His sentence is not based on what he's available to do," Gibbons said. "His sentence is what he's going to do, or he's going to go to state prison for four years."
Dressed in a light plaid suit, Brown answered "guilty" when asked his plea by Assistant District Attorney Mary Murray.
Formal sentencing was set for August 5.
After the hearing, Geragos said of Brown, "as long as I've known him in connection with this case, he's wanted to take responsibility."
He said Brown is thankful to those who offered him support and noted that he is "a kid who's never been in trouble before" who wants to "move past this" and get out the message that domestic violence is not acceptable.
Brown "embraces this as an opportunity to get his life back on track and get his career back on track," Geragos said, adding that Brown will speak further after his sentencing.
Etra said after the hearing that Rihanna "was fully prepared to testify and she would have told the truth about what happened that evening." He said she did not object to the plea agreement.
Rihanna had not attended any of the hearings in the case but had been following the case closely, Etra said earlier.
She did not file a complaint against Brown, but the prosecution's case was built on what she told detectives and on physical evidence collected from her, including photographs of her bruised and battered face.
It was not Rihanna who called police but someone who heard her screams for help, according to a sworn statement by Los Angeles Police Detective DeShon Andrews.
The statement, filed with the court to support a search warrant for cell phone records, described a brutal attack against Rihanna, allegedly by Brown.
Andrews said the incident began when Rihanna, who was riding in the sports car driven by Brown, found a text message on his cell phone from "a woman who Brown had a previous sexual relationship with."
"A verbal argument ensued," followed by the physical attack, the statement said. It went on to describe the assault in great detail, saying Brown punched her numerous times and put her in a head lock, restricting her breathing and causing her to start to lose consciousness. He threatened to "beat the s--t out of you" and kill her, according to the statement, and also bit her ear and her fingers.
Eventually, "Robyn F. began screaming for help and Brown exited the vehicle and walked away. A resident in the neighborhood heard Robyn F.'s plea for help and called 911, causing a police response. An investigation was conducted and Robyn F. was issued a Domestic Violence Emergency Protective Order."
At the end of his statement, the detective said Brown sent a text message nine days later, apologizing.
Brown also issued a public apology for the incident just days after his arrest.
"Words cannot begin to express how sorry and saddened I am over what transpired," he said in a statement released by his spokesman. "I am seeking the counseling of my pastor, my mother and other loved ones and I am committed, with God's help, to emerging a better person."
CNN's Denise Quan contributed to this story.