He was leaving a motorcycle dealership in south Florida on Monday when a gunman shot him.
Police in Broward County said XXXTentacion, whose real name is Jahseh Onfroy, was taken to hospital where he was pronounced dead.
He was often described as one of rap’s most controversial artistes and was facing domestic violence charges.
The rapper, who first found an audience by uploading songs to the website SoundCloud, had been hailed as a breakthrough talent and tributes have been pouring in from hip-hop luminaries in the wake of his death.
The county sheriff’s office said that Onfroy was leaving the dealership shortly before 16:00 local time when two armed suspects approached him.
At least one of them shot him before both fled the scene in Deerfield Beach, which is 43 miles (69km) north of Miami, in a dark-colored SUV.
Investigators said it appeared to be a “possible robbery”. A video posted on social media apparently showed Onfroy slumped in his car.
A witness told celebrity news website TMZ that multiple shots rang out outside the dealership. The rapper, whose hit songs include ‘SAD’ and ‘Moonlight’, quickly rose to prominence following the release of his debut album ‘17’ last August.