Troubled rapper-singer XXXTentacion was shot and killed Monday in Florida in what police called an apparent robbery attempt.

The 20-year-old rising star, whose real name is Jahseh Dwayne Onfroy, was pronounced dead Monday evening at a Fort Lauderdale-area hospital, the Broward Sheriff's Office said. He was shot earlier outside a Deerfield Beach motorcycle dealership.

Investigators surround a vehicle after the shooting. Authorities say XXXTentacion was in his car when two armed suspects approached him, and at least one opened fire. (John McCall/South Florida Sun-Sentinel/Associated Press)

XXXTentacion had been at RIVA Motorsports checking out inventory, sheriff's public information officer Keyla Concepcion said. He was in a black BMW i8 and preparing to leave before 4 p.m. local time when two armed suspects approached him. At least one of them fired, and then both suspects fled the scene in a dark SUV, Concepcion said. Investigators don't have a motive, and no arrests have been made.

Stephanie Martinez, a 29-year-old mother who lives in the neighbourhood, was just coming back from the pool with her kids when she heard three shots. She drove to the end of the street and saw the rapper's body in the car.

"He has his mouth open and his hand out. Two people went over and checked his pulse," said Martinez, who also saw blood. "It's just weird because he should've had security and stuff with him."

'Thanks for inspiring me'

On Twitter, his peers expressed shock and sadness.

Kanye West said: "rest in peace ... I never told you how much you inspired me when you were here thank you for existing." Producer Diplo posted a photo of the two together and said, "Thanks for inspiring me." Travis Barker tweeted: "I'm at a loss for words... speechless #RIPXXXTentacion Loved collaborating with you. You were a true artist ..."

And J. Cole said, in part: "RIP X. Enormous talent and limitless potential and a strong desire to be a better person. God bless his family, friends and fans."

Thanks for inspiring me. <a href="https://t.co/BmX3ya6Hmx">pic.twitter.com/BmX3ya6Hmx</a> —@diplo

The entertainer, who sported dreadlocks and a number of facial tattoos, was a rising star and notched a No. 1 album in March with his sophomore effort ? and had a top 10 hit with Sad! but was facing trial on charges that he beat up his pregnant girlfriend.

XXXTentacion racked up huge streaming numbers — on Spotify, his Sad! had more than 270 million streams and was on its Top 50 chart this week in the United States and globally. He also has several songs that have been declared platinum, including Changes, Roll in Peace with fellow rapper Kodak Black and Look at Me!

'I'm one of the greatest'

In interview with XXL magazine, which named him an up-and-coming artist last year, the rapper cited Nirvana, the Notorious B.I.G. and Tupac Shakur among his musical influences.

"Obviously, I'm one of the greatest of this generation, the upcoming generation, as far as artistry.... And I say that humbly," he said in a video interview with the outlet last year.

But much of his brief career had been mired in controversy. In 2016, he was arrested on charges including home invasion for a 2015 incident, and less than a month later was arrested on charges that he attacked his girlfriend, who was pregnant at the time, and was jailed, and later faced more charges including witness tampering.

Regarding a June 2017 attack at a San Diego concert, the following messages were posted on XXXTentacion's Twitter account: "security and venue set me up, I got sucker punched and knocked out, it is what it is."

A subsequent tweet said," "next time make sure you kill me so I can't talk [expletive]."

'Couldn't have come at a worse time'

He was released from jail on house arrest late last year and was released from house arrest earlier this year to allow him to tour.

Fan Wyatt Rubin, 21, jumped in his car and headed to the scene shooting Monday as soon as he heard, playing the rapper's songs like Jocelyn Flores and King on the drive over.

"He was just maturing as a person and as an artist.... It couldn't have come at a worse time," Rubin said. "A lot of it was really beautiful music, progressive music."'

In an interview earlier this month with the Miami New Times, XXXTentacion described his upbringing, which included seeing his mother infrequently and being raised by friends, other family and babysitters. His mother would buy him clothes, phones and other gifts. He told the paper he used violence so she would engage with him.

"I used to beat kids at school just to get her to talk to me, yell at me," he said.

Addressed depression

XXXTentacion was initially one of two artists Spotify removed from its promoted playlists in May in accordance with its new policy on hateful music and conduct. But after a backlash in the music industry, Spotify backpedalled and said it would no longer attempt to police conduct and restored XXXTentacion to its playlists (although they did not do the same for R. Kelly).

While he made headlines for his legal woes, he connected to millions of fans musically. Among the topics he spoke about was depression and addressed it in his music.

In one video posted to social media, he said: "If worse things come to worse, I [expletive] die a tragic death or some [expletive], and I'm not able to see out my dreams, I at least want to know that the kids perceive my message and were able to make something of themselves."

He continued later: "I appreciate and love all of you and I believe in you all; do not let your depression make you, do not let your body define your soul, let your soul define your body. Your mind is limitless.... You are worth more than you can believe."