New evidence in the investigation into XXXTentacion’s shooting death has revealed details about his murder, including XXX being targeted by his killers, how the rapper struggled for his life before he was fatally shot, and how police eventually collared one of the men responsible for his death.

According to a detective’s sworn affidavit, the 20-year-old’s killers were tracking him in his final moments Monday afternoon (Jun. 18).

RELATED: XXXTentacion’s Alleged Murderer Dedrick D. Williams Is a Tattoo Artist Who Flashed Money on Instagram All the Time

The affidavit states that the main suspect in the shooting, 22-year-old tattoo artist Dedrick Williams, and another man followed XXX into RIVA Motorsports before shooting and robbed him in his car less than a half hour later. The court documents also say that XXXTentacion (real name: Jahseh Dwayne Onfrey) was specifically targeted in the attack.

Surveillance footage from outside the motorcycle shop, as well as from inside the business, captured two men entering the dealership while XXXTentacion shopped. The CCTV video also recorded the moment he was ambushed while leaving the bike shop’s parking lot.

RELATED: XXXTentacion’s Last Photo, Rapper Pictured at RIVA Motorsports Right Before He Was Shot & Killed

Onfroy had brought a friend along with him to browse at the dealership where he was a regular customer. What happened to his passenger, and why the rapper was targeted, were not described in the court docs. Onfroy’s attorney, David Bogenschutz—who had previously warned XXX to become more aware of his security—said he believes his client had gone to a bank before traveling to RIVA motorsports.

Onfroy drove his BMW to the motorcycle dealer at about 3:30 p.m. Monday afternoon. About two minutes later, a dark-colored SUV arrived and parked in the dealer’s lot. Two men exited the SUV, one wearing a white tank top and bright orange sandals and the other wearing a dark T-shirt, and entered the store.

The man in the white tank and orange sandals, later identified as Williams, paid cash for a black mask, and the men left the store. They returned to the SUV and backed it into a homeowner’s driveway across the street from the dealership.

At 3:55 p.m., when Onfroy’s BMW was exiting the dealership’s lot, the SUV pulled in front of it, blocking Onfroy in. An eyewitness told detectives two armed men dressed in dark clothing and gloves—one wearing a red mask and the other in a black mask—approached the driver side of the rapper’s vehicle.

XXX briefly struggled with the masked men, who then shot the rapper multiple times before reaching inside the BMW and taking his Louis Vuitton bag. XXX was hit in the neck and died instantly, witnesses said. The masked men fled the scene immediately after the shooting.

Broward Sheriff’s deputies were able to quickly identify Williams because he was seen wearing the same orange sandals he had on when he killed XXXTentacion in multiple photographs posted to Instagram and Facebook. Williams’ identity was also confirmed by eyewitnesses and employees of the shop. Within 48 hours, Williams was taken into police custody and charged with first-degree murder for X’s shooting death.

WATCH: XXXTentacion’s Alleged Killer Dedrick Williams Charged With Murder in 1st Court Appearance, Denied Bond

According to Williams’ arrest report, police contact was made with him as he drove a 2004 silver Honda Accord, which he was driving without a valid license and a suspended ID. The records accuse Williams of murdering XXXTentacion with “a premeditated design to effect the death of a human being, Jahseh Onfroy” and allege he did “have an active part and did kill and murder by shooting him with a deadly weapon, to wit: a gun.”

WATCH: Dedrick D. Williams’ Brother Says Williams Didn’t Kill XXXTentacion

Williams appeared in court the day after his arrest and was denied bond. The Broward County Sheriff’s Office said they were “seeking additional suspects” still at large. Williams’ brother posted a video on social media denying Williams’ involvement in the shooting.

Though police don’t believe Williams is the one who actually pulled the trigger, his active role in the homicide led to him being arrested on a premeditated murder charge.

Be the first to receive breaking news alerts and more stories like this by subscribing to our mailing list.