Daniel Hernandez, known as Tekashi 6ix9ine. (AP Photo/Luca Bruno, File)

Rapper Tekashi 6ix9ine pleaded guilty to nine counts of racketeering conspiracy, firearms and narcotics trafficking charges in his ongoing criminal case and will cooperate with federal prosecutors, according to recently unsealed court documents. The charges relate to his involvement in a violent gang in New York called the Nine Trey Gangsta Bloods.

Tekashi, whose real name is Daniel Hernandez, stated in a trial held last week that he joined the gang in fall 2017. Its members engaged in various criminal acts to "preserve and enhance the power of Nine Trey," he said, adding that he had helped others rob people and once paid someone to shoot at a rival gang member to "maintain or increase my own standing in Nine Trey." Hernandez, 22, also said he sold heroin and participated in the attempted murder of another gang rival.

"At all times I knew that these actions were wrong and in violation of the law," he said. "I apologize to the court, to anyone who was hurt, to my family, friends and fans for what I have done and who I have let down."

Hernandez's sentencing date has not yet been determined. He could face up to life in prison, though it is unclear if or how his cooperation with authorities will affect the sentence.

Hernandez gained a following as a SoundCloud rapper, as those who release their music through the streaming platform are known. Along with XXXTentacion, who was fatally shot last summer, Hernandez represented a sect of the hip-hop scene that deviated from the norm. New York Times music critic Jon Caramanica described him as a "brute-force screamer," in that he "thrives on raps and repetition, as if constantly looking to pick a fistfight."

Hernandez's debut single "Gummo" rose to No. 12 on the Billboard Hot 100 and was certified platinum. As a mainstream artist, he released the song "Fefe" with Nicki Minaj, which rose to No. 3. His debut album, "Dummy Boy," came out in late November and debuted at No. 2 on the Billboard 200.

This fame overlapped with a long history of legal troubles. This past October, Hernandez avoided jail time after admitting to having made and distributed sexually explicit videos of a 13-year-old girl in 2015. He was sentenced to four years of probation and 1,000 hours of community service, while the man in the video went to jail.

Hernandez and five other Nine Trey members were indicted in November. Geoffrey Berman, U.S. attorney for the Southern District of New York, said in a statement that they "wreaked havoc on New York City, engaging in brazen acts of violence."

In a statement shared shortly afterward with The Washington Post, Hernandez's attorney Lance Lazzaro claimed his client was "completely innocent of all charges being brought against him."

"An entertainer who portrays a 'gangster image' to promote his music does not make him a member of an enterprise," Lazzaro wrote in November. "Mr. Hernandez became a victim of this enterprise and later took steps by firing employees and publicly denounced this enterprise through a morning show. Threats were then made against his life which resulted in this case being brought immediately."

On Friday, Lazzaro did not respond to The Post's request for comment on Hernandez's guilty plea.