Lil Nas X has set a new Billboard record.

The rapper's collaboration with Bill Ray Cyrus, "Old Town Road," is now the longest-running No. 1 single in American music history. It's been at the top of the Billboard Hot 100 for 17 weeks.

Billboard reported that the feat breaks the 16-week record initially set in 1995 by Mariah Carey and Boyz II Men with "One Sweet Day." Luis Fonsi, Daddy Yankee and Justin Bieber tied with the 1995 single with 2017's "Despacito."

Carey still has the record for the most time at No. 1 at 79 weeks. The Beatles have the most No. 1s with 20, according to Billboard.

Nas X told Time in April that he wrote the song when he was struggling.

"'Old Town Road' came after a period of feeling like I was out of options," he said. "I was living with my sister. She was pretty much fed up with me being there. That’s where the chorus lyric came from. It was me saying, 'I want to leave everything behind.'"

>> Read more trending news

It's been an up and down road for the single, which initially made mainstream waves when it was removed from Billboard's Hot Country Songs chart. The song blurs genre lines across country and hip hop. It was initially released as a solo single in December 2018. It's the solo version which cracked the country charts before it was removed.

"Upon further review, it was determined that 'Old Town Road' by Lil Nas X does not currently merit inclusion on Billboard's country charts," a spokesperson for Billboard said in a statement to Rolling Stone in March. "When determining genres, a few factors are examined, but first and foremost is musical composition. While 'Old Town Road' incorporates references to country and cowboy imagery, it does not embrace enough elements of today's country music to chart in its current version."

Nas X went on to collaborate with country singer Cyrus on a remix of the song, which was even more successful than the original single. They performed the song at Stagecoach and the BET Awards. He also released official remixes with DiploYoung Thug and Mason Ramsey and RM of BTS, which contributed to the 17-week run at No, 1, according to Billboard.

Lil Nas X and Billy Ray Cyrus attend the 2019 BET Awards on June 23, 2019 in Los Angeles.

Credit: Lil Nas X and Billy Ray Cyrus attend the 2019 BET Awards on June 23, 2019 in Los Angeles. Frazer Harrison/Getty Images

icon to expand image

Credit: Lil Nas X and Billy Ray Cyrus attend the 2019 BET Awards on June 23, 2019 in Los Angeles. Frazer Harrison/Getty Images

In April, the 20-year-old spoke about the removal of the song from the Hot Country Songs chart.

"The song is country trap," he told Time. "It's not one, it's not the other. It's both. It should be on both.

"I believe whenever you’re trying something new, it’s always going to get some kind of bad reception. For example, when rap started, or when rock and roll began. But with country trap, I in no way want to take credit for that. I believe Young Thug would be one of the biggest pioneers in that."

A list of the top 10 longest-running No. 1s in Hot 100 chart history, from Billboard, is below.

1. "Old Town Road" by Lil Nas X feat. Billy Ray Cyrus, released April 13, 2019 (17 weeks)
2. "Despacito," by Luis Fonsi & Daddy Yankee feat. Justin Bieber, released May 27, 2017 (16 weeks)
3. "One Sweet Day" by Mariah Carey & Boyz II Men, released Dec. 2, 1995 (16 weeks)
4. "Uptown Funk!" by Mark Ronson feat. Bruno Mars, Jan. 17, 2015 (14 weeks)
5. "I Gotta Feeling" by The Black Eyed Peas, released July 11, 2009 (14 weeks)
6. "We Belong Together" by Mariah Carey, released June 4, 2005 (14 weeks)
7. "Candle in the Wind 1997"/"Something About the Way You Look Tonight" by Elton John, released Oct. 11, 1997 (14 weeks)
8. "Macarena (Bayside Boys Mix)," by Los Del Rio, released Aug. 3, 1996 (14 weeks)
9. "I'll Make Love to You" by Boyz II Men, released Aug. 27, 1994 (14 weeks)
10. "I Will Always Love You" by Whitney Houston, released Nov. 28, 1992 (14 weeks)

What You Need to Know: Lil Nas X