Image copyright Getty Images Image caption XXXTentacion (L) was gunned down after leaving a motorcycle dealership in Florida

The life of US rapper XXXTentacion, who was shot dead outside a motorcycle dealership on Monday, was as grim and confusing as his music was compelling.

Born Jahseh Dwayne Onfroy in south Florida, he had a troubled upbringing that was often punctuated by violence.

His mother was a teenager when he was born and flitted in and out of his life. He was raised by his grandmother, family friends and babysitters - and once said he used violence to make his mother pay attention.

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

Despite that, he was fiercely protective of their relationship, once claiming that when he was six years old he "bit [the] flesh out" of a man who laid his hands on her.

He was later expelled from middle school for fighting, but he soon channelled his energy and fury into music.

The 20-year-old became the most popular artist in the genre known as SoundCloud Rap, defined by its languid, hazy beats and wide-ranging influences - comprising everything from hardcore hip-hop to grunge and indie.

From the outset XXXTentacion's songs were visceral and abrupt. His breakout single Look At Me! sounded like it was being played through a smashed-up phone speaker - but he was also capable of disarming fragility and tenderness.

On his debut album, 17, he talked sensitively about depression and mental anguish, largely forsaking hip-hop beats for acoustic guitars and smudged, sullen melodies.

Rapper Kendrick Lamar was one of many high-profile supporters, tweeting "listen to this album if you feel anything. raw thoughts" - and the record peaked at number two on the US charts.

His surging popularity was noted by the music industry and, by October 2017, he had scored a distribution agreement reportedly worth $6 million (£4.5m) between his own record label and Caroline Records, which also represents Van Morrison and Chrissie Hynde.

But the teenager's career was already being overshadowed by his violent behaviour, including charges of aggravated battery of a pregnant woman, domestic battery by strangulation and, later, witness tampering.

The accusations, which Pitchfork explained in harrowing detail last year, suggest a pattern of routine abuse that would have resulted in a substantial prison sentence, had the case gone to trial.

Onfroy pleaded not guilty and laughed off the allegations in a profanity-strewn tirade on social media, calling the charges "fabricated" and pledging to donate $100,000 to domestic violence-prevention programmes (it is unclear whether the payment ever materialised).

He also continued to court controversy, releasing a provocative music video earlier this year in which, to make a point about racism, he put a noose around the neck of a young white child. He later gave an interview in which he argued against feminism.

Image copyright Miami Dade County Corrections/Getty Image caption XXXTentacion's mugshot from December 2017

Fans were apparently unswayed by - or attracted to - the star's tribulations; sending his latest album ? to number one in the US. The album also produced his only UK hit, a desolate heartbreak song called SAD.

The star's manager reflected that Onfroy's volatile life was what made his music so compelling. "He's just a young kid that was lost and needed a chance in life," Solomon Sobande told Billboard magazine last year.

"So much stuff around him touched my heart. I just came to the point like, 'I gotta help this kid.'"

However, many found it impossible to separate his music from his actions; and Spotify briefly blacklisted Onfroy's songs from its service earlier this year.

His death in an apparent drive-by shooting will undoubtedly reignite interest in the star's all-too-brief career.

New listeners will hear his pain and the all-too-familiar price of neglect and deprivation - but they should also take time to question why violence is so frequently used to signify credibility in music.

If you, or someone you know, has been affected by domestic abuse or violence, the organisations listed on this page can help.

Follow us on Facebook, on Twitter @BBCNewsEnts, or on Instagram at bbcnewsents. If you have a story suggestion email entertainment.news@bbc.co.uk.