NEW YORK - Bobby Shmurda, the young rapper whose celebrity was fast growing until his 2014 arrest, was sentenced Wednesday to seven years in prison on weapons charges.

A New York court handed the sentence to the 22-year-old rapper, whose real name is Ackquille Pollard, in line with a plea deal which he sought to reject at the last minute.

“I was forced to take this sentence,” Shmurda told the judge, according to the New York Daily News and tweets from inside the courtroom. But Judge Abraham Clott confirmed the seven-year prison term, ruling that there was no need for more time to review the case.

Shmurda’s career boomed in the months before his arrest thanks to his song “Hot Nigga,” which is full of references to guns and street life. The song - edited for mainstream radio as “Hot Boy” - climbed to number six on the US singles chart.

The song went viral thanks to the accompanying “Shmoney Dance,” which features moving elbows in and out. Pop stars including Taylor Swift and Justin Bieber soon showed off their own Shmoney moves.

In signs of a burgeoning career, Shmurda was signed to Epic Records and performed on the late-night show “Jimmy Kimmel Live” days before his arrest.

Prosecutors said that Shmurda was part of a gang involved in shootings against rivals in Brooklyn, with police reporting that they seized 21 guns from Shmurda and seven associates.

Shmurda, who argued that his gun was a prop, last month accepted the deal to plead guilty to two counts in return for the seven-year sentence, which includes time already served.

Such plea bargains are common in the US judicial system. Shmurda told Complex magazine last month that his lawyer warned him that he would struggle to make his case in court.

“Who are they going to believe, the word of this black kid talking about shooting shit up or the word of white officers?” he said.