The culture of hip-hop has been used as a tool to divert young minorities from falling into a life of crime, and has been credited with saving an innumerable amount of lives over the course of the past 40 years. From transforming criminal-minded street gangs into creative ensembles and collectives, to providing those stuck in the system a hobby and a new lease on life, hip-hop has been considered a safe haven and a home for many who were unfortunate enough to never have one. However, throughout the years, hip-hop has seen quite a few artists get caught up in the legal system after attaining fame and fortune, many of them paying the ultimate price and losing their freedom as a result of their actions.

2016 has been a wild year for hip-hop in terms of legal troubles. While the actual music hasn't let us down, the same can't be said about some of our favorite rappers, young and old, who got caught in cuffs over the course of the year, some risking the loss of their career. On the flip side, the music industry and its players have been known to be shiesty in their own right (word to A Tribe Called Quest), causing for litigation due to contractual red tape or financial misdealings. From Troy Ave shooting a gun inside Irving Plaza in New York City to Lil Wayne's lawsuit against Cash Money to Kodak Black's incarceration for much of the year, hip-hop saw the inside of a courtroom more than a few times.

With the year now coming to a close, XXL examines 20 of the more intriguing legal battles involving rappers that grabbed headlines during 2016.

More From XXL