The moment rapper XXXTentacion was shot dead at the wheel of his BMW has been shown to the trial of four men charged with his murder.

The 20-year-old, born Jahseh Dwayne Onfroy, had been visiting Riva’s MotorSports in Pompano Beach, Florida, when he was robbed and shot dead in broad daylight on 18 June.

A CCTV clip, played at Broward County Court for the first time during a hearing on Thursday, showed the rapper walking into the dealership followed closely by two men who buy masks and then leave.

The rapper is seen getting back into his £115,000 BMW and prepare to leave the car park when a dark-coloured Dodge Journey 4x4 blocks his exit.

Video footage shows two masked men jumping out of the passenger side doors of the car and racing over to him.

The pair then lean into the rapper’s window and point a handgun and rifle at him while demanding the chain around his neck but he refuses to co-operate, according to the Miami Herald.

A struggle ensues and the 20-year-old is shot dead at point-blank range.

The men fled the scene with a Louis Vuitton bag containing $50,000 (£38,000) in cash, police said.

The footage was played during a bail hearing for suspect Robert Allen, who is charged with the murder along with three other suspects.

Allen, Michael Boatwright, Dedrick Williams and Trayvon Newsome all faces charges of first-degree murder and robbery with a firearm, according to court records.

The sister of XXXTentacion, Ariana Onfroy, 22, believes the murder was an “inside job”.

Rapper XXXTentacion attends the BET Hip Hop Awards 2017 at The Fillmore Miami Beach a year ago (Bennett Raglin/Getty Images for BET)

She told the Sun Online: “There's somebody on the inside that knew where he was going to be and the exact time he was leaving for the murderers to know when to come and to do what they did. It definitely was set up.”

XXXTentacion, who sported dreadlocks and facial tattoos, was a platinum-selling rising star who first found fame while uploading songs to online audio distribution platform SoundCloud.

He amassed a loyal following due to his emotionally moving lyrics that addressed his suicidal thoughts and experiences with depression.

In March, he secured a number one album in the US with his second release ? and had a top 10 hit with “Sad!” in the same month.

In one video on social media, he said: “If worse things come to worse, I f***ing die a tragic death or some s***, 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 later added: “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.”

No longer languishing in a vault: the late rapper XXXTentacion (Getty Images)

During his lifetime and career, XXXTentacion drew criticism over bad behaviour and multiple arrests, and was facing 15 felony charges at the time of his death.

He was sent to a youth detention centre for gun possession charges at the age of 16.

In October 2016, the rapper was arrested and later charged with aggravated battery of a pregnant woman, domestic battery by strangulation, false imprisonment and witness tampering.

In 2016, he was arrested and charged with robbery and assault with a deadly weapon.

Shortly after his death, X’s mother Cleopatra revealed his girlfriend was pregnant with their first child.