Los Angeles (CNN) -- Justin Bieber must pay $80,900 restitution for damage caused to his former neighbor's mansion by eggs he threw.
The pop star accepted a plea deal to settle a vandalism charge that puts him on probation for two years. The probation will be supervised until he completes 12 weekly anger management sessions, works five days of community labor and pays the restitution.
The sentence also requires Bieber to stay at least 100 yards way from the victim's family.
Bieber must let the probation officer know if he is deported or otherwise leaves the country, Los Angeles County Superior Court Judge Leland Harris said.
"Justin is glad to get this matter resolved and behind him," his representative said in a written statement. "He will continue to move forward focusing on his career and his music."
The misdemeanor charge was filed Wednesday morning by the Los Angeles County District attorney five months after a sheriff's investigator recommended it be prosecuted as a felony.
Assistant District Attorney Alan Yochelson told the judge that while the damage to Jeffrey Schwartz's "dream house" was "incredible" he did not think it warranted a felony charge.
Yochelson called it "an extremely immature and silly act" that caused "incredible amount of damage" to what the neighbors considered their "dream house."
Bieber's lawyer previously called it a "silly prank."
Bieber, 20, was not required to be in court. Attorney Shawn Holley, known for her frequent appearances defending Lindsay Lohan, entered the "no contest" plea on his behalf in a Van Nuys, California, court Wednesday afternoon.
The vandalism case is what lawyers call a "wobbler," meaning the district attorney could have prosecuted it as a felony -- which would have much more serious consequences for the singer -- or as a misdemeanor.
Bieber has since moved from the neighborhood, selling the mansion to Khloe Kardashian.
Bieber's drunken driving charge in Miami is also still pending, although a source close to that case said talks are under way to reach a plea deal to avoid a trial.
Los Angeles prosecutors decided in June not to pursue charges against Bieber for an incident in which a Los Angeles woman accused him of trying to take her cell phone.
The egging case began when the singer's neighbor called 911 to report that someone was throwing eggs over a fence from Bieber's home. Residents of the exclusive community had previously reported several incidents allegedly involving Bieber, including speeding on the residential streets.
Investigators with the Los Angeles County Sheriff's Department searched Bieber's home on January 14 for video from Bieber's security cameras they hoped would show what happened. They later presented prosecutors of video they said supports a vandalism charge against Bieber, an investigator said.
Bieber house guest Lil Za, a rapper whose real name is Xavier Smith, was arrested on a felony drug charge during the raid. Deputies added a vandalism charge when he damaged a jail phone. He later accepted a plea deal for probation.