httpss://www.youtube.com/watch?v=vJwKKKd2ZYE

After spending over a year and a half in jail awaiting trial, the Brooklyn rapper Bobby Shmurda pleaded guilty on Friday to conspiracy and weapons possession in a deal with prosecutors three days before jury selection was to start.

Justice Abraham Clott promised Shmurda, whose legal name is Ackquille Pollard, a sentence of seven years in prison in return for his guilty plea.

As he entered his plea, Mr. Pollard, 22, leaned far back in his chair, his head rolling and his eyes nervously skipping around the audience in State Supreme Court in Manhattan.

Mr. Pollard was arrested outside Quad Recording Studios in December 2014 in Manhattan and accused of being a leader in GS9 – or G Stone Crips – a violent street gang in East Flatbush, Brooklyn, that the police said was responsible for one murder and several shootings.

Mr. Pollard had been a rising star in hip-hop, with a debut album on the horizon after the chart success of a self-produced single – “Hot Boy” in its edited form – that was bolstered by a dance craze on the video app Vine.

Epic, a subsidiary of Sony Music, did not immediately respond to a request for comment about Mr. Pollard’s plea deal or status at the label.

Two of Mr. Pollard’s co-defendants, Rashid Derissant, 24, and Alex Crandon, 22, were convicted in April of murder and conspiracy, among other charges, after a long trial.

As Justice Clott presented the prosecution’s final offers for plea bargains to Mr. Pollard and three co-defendants on Friday, he made it clear they would all face decades in prison if they were convicted at trial.

Mr. Pollard’s lawyer, Alex Spiro, said in a statement that the rapper would receive credit for time served, which would “Hopefully permit him to be home in approximately three and a half years and resume his remarkable career.”

Bobby Shmurda