The 20-year-old's song just broke the record as his single spends its 17th week atop the Hot 100 chart.
Mariah Carey and Boyz II Men's "One Sweet Day" previously set the record in 1996 — with the only song coming close to breaking it was the hit "Despacito," which tied the 16-week record in 2017.
"YEEE TF HAWWW," Lil Nas X tweeted on Monday in response to the news.
Hours later, he posted a video thanking his fans for helping his song set a new record.
"I'm on the toilet right now, but I want to say thank you to every single person who has made this moment possible for me. We just broke the record for the longest-running No. 1 song of all-time," said Lil Nas X, sporting a cowboy hat as he played "Old Town Road" in the background. "Let's go!"
"Old Town Road," which has achieved most of its success through audio streaming, was originally a solo song, but Lil Nas X added Billy Ray Cyrus to the track.
The song also has remix versions featuring Diplo, Young Thug, Mason Ramsey and BTS, and Billboard counts the original song and its remixes as one when calculating chart position, thus helping "Old Town Road" stay on top.
"17 is my new favorite number," Cyrus said in a statement Monday, also referring to his debut album "Some Gave All," which spent 17 weeks at No. 1 in 1992. "My goal was always to make music that would touch people's lives around the world."
Mariah Carey also took to Twitter to congratulate Lil Nas X on his accomplishment.
"Sending love & congrats to @LilNasX on breaking one of the longest running records in music history! We've been blessed to hold this record with a song that means a great deal to @BoyzIIMen and myself and has touched so many. Keep living your best life!" Carey wrote on Monday.
"Old Town Road" initially was in a bit of controversy in March when Billboard removed it from its country charts, deeming it not country enough (it peaked at No. 19 on the country charts). But the drama didn't hurt the song; it only propelled it.
Songs have come close to displacing "Old Town Road" from the top spot — including Billie Eilish's "Bad Guy" and a pair of Taylor Swift singles — but ultimately were unsuccessful.
Swift was successful in 2017 when her song "Look What You Made Me Do" stopped Luis Fonsi, Daddy Yankee and Justin Bieber's "Despacito" from reaching a 17th week at No. 1. Celine Dion's "Because You Loved Me" ended Carey and Boyz II Men's epic run in 1996.
The Associated Press contributed to this report