Image copyright Getty Images

Tekashi 6ix9ine has been sentenced to two years in prison for crimes he carried out while he was a member of a violent gang.

The rapper, whose real name is Daniel Hernandez, pleaded guilty to racketeering and other offences in New York.

The 23-year-old initially denied the charges but entered a plea bargain, giving evidence against other gang members in order to get a reduced sentence.

The 13 months he's spent in jail already will be included.

The rapper had been facing a minimum of 47 years and a maximum of life in prison but the plea bargain means he could be released around November 2020.

He testified against former members of Nine Trey Gangsta Bloods.

The offences 6ix9ine was charged with include racketeering, carrying a firearm, assault with a dangerous weapon, and conspiracy murder charges.

Racketeering is when people use criminal actions to repeatedly take money from others, often associated with protection rackets.

Image copyright Getty Images Image caption Tekashi 6ix9ine performing at a concert

It all came from his association with a violent US gang Nine Trey Gangsta Bloods - also known as TreyWay - which 6ix9ine previously mentioned on Twitter.

He joined the gang in 2017 but left less than a year later.

The inner workings of the gang was exposed by 6ix9ine - and another ex-gang member, Kristian Cruz.

Nine Trey Bloods committed robberies, dealt drugs and were violent against rivals and each other according to their testimonies.

6ix9ine gave information on Anthony Ellison and Aljermiah Mack and both men have since been convicted.

Ellison was also found guilty of kidnapping 6ix9ine, maiming and assault - while Mack was also found guilty on drug dealing charges.

Media playback is unsupported on your device Media caption 'They're calling him Tekashi Snitch 9ine'

On the day before sentencing, two victims from an armed robbery on 3 April 2018 in midtown Manhattan submitted witness impact statements, according to Billboard.

They detailed how they've suffered because of the attack.

The first victim said in his statement that the attack "set my life on the wrong course, and destroyed the normal adulthood that I was striving for."

He added: "Never have I been so scared as the cold, hard metallic gun was pressed against my abdomen."

The other victim said in her statement: "As a result of this entire ordeal, I have suffered greatly from mental anguish and emotional distress. So traumatised by this aftermath, that over a year later, I have had a difficult time getting past the incident suffering from what we believe is post-traumatic stress disorder."

She also detailed the impact of "the video of me escaping from the clutches of his thugs on social media and it went viral accumulating millions of views as the public laughed."

"Ever since, I find myself unable to do the simple things an adult should do."

'He intends to resume his career'

Lisa Evers has been covering the trial for local station Fox 5 News, and says although Tekashi 6ix9ine may have turned his back on his former gang associates, he definitely hasn't turned his back on music.

She told Newsbeat he "he may possibly go overseas in order to live where he can be safe, because there are many people, as you can imagine ... that are looking to do harm to him because of his testimony.

"If it's not safe for him in the United States, I'm told that he could go to the UK or Europe, or even Asia to perform. But he intends to resume his career."

Follow Newsbeat on Instagram, Facebook, Twitter and YouTube.

Listen to Newsbeat live at 12:45 and 17:45 weekdays - or listen back here.