Lil Nas X is using his popularity to jack old songs and rack up millions of views -- and dollars -- without rights to do so ... according to a new lawsuit.

The 20-year-old rapper -- who's been the hottest thing in hip-hop and possibly country this year -- is being sued, along with Sony, by a company called The Music Force for jacking the 1982 Bobby Caldwell song, "Carry On."

According to the suit ... X posted a track on YouTube, Spotify and Soundcloud that appropriated parts of "Carry On" without permission, and as of early July it had nearly 4 million YT views.

The Music Force alleges Lil Nas was "motivated by greed and malicious intent."

The company is also suing Sony because it recently signed the rapper to a record deal ... and it says it should made sure its artist got the song cleared.

The Music Force is asking for a whopping $25 million, claiming X has destroyed the value of its Bobby Caldwell song by jacking it.