A judge has agreed to dismiss charges against Fetty Wap stemming from a fight last year at a Las Vegas hotel if the rapper stays out of trouble.

An attorney for Fetty Wap, whose real name is Willie Maxwell, entered into the agreement with prosecutors Monday to toss the misdemeanor battery charges in July, court records show. The rapper wasn't in court.

His attorney, Adam Graves, didn’t immediately respond to messages Wednesday.

Fetty Wap was arrested Sept. 1 after he was accused of hitting a security officer who arrived to break up a scuffle at a valet area of The Mirage resort on the Las Vegas Strip. He had performed at the MTV Video Music Awards a day earlier.

In March 2018, the rapper was fined in Brooklyn, New York, and ordered to attend safe driving programs after pleading guilty to driving while intoxicated and reckless endangerment. Police said he had been caught drag racing on a New York City-area highway.