(CNN) Tekashi 6ix9ine, the flamboyant Brooklyn rapper who carried out a series of violent crimes before informing on his former gang associates, was sentenced to 2 years in prison on Wednesday.

He had pleaded guilty to racketeering, firearms and drug trafficking charges related to several shootings and assaults around New York City. He was also sentenced to five years supervised release plus 300 hours of community service. Because he has already served about 13 months behind bars, he is due to be released late next year.

In making the decision, Judge Paul Engelmayer said that Tekashi 6ix9ine, born Daniel Hernandez, was a "central figure in a vicious and brutal gang." Engelmayer said he caused mayhem around the city and used the gang as his "personal hit squad."

However, Engelmayer balanced those crimes with the rapper's extensive cooperation with government investigators. Prosecutors had requested that he receive a reduced sentence because of his "extraordinary" and "substantial" cooperation.

His attorney Lance Lazzaro had asked the court to sentence him to time served, highlighting the risks that Hernandez took in cooperating with the government. Hernandez provided investigators with an "insider's view" of the Nine Trey gang, Lazzaro wrote in court filings, and even testified against two former gang members.

Read More