Juice WRLD, who rapped about his struggles with substance abuse and achieving meteoric success, died of an accidental drug overdose during a December drug raid at Midway Airport in Chicago, a medical examiner ruled on Wednesday.

The rapper, whose real name was Jarad A. Higgins, died on Dec. 8 as a result of oxycodone and codeine toxicity, the Cook County Medical Examiner’s Office said. He was 21.

The autopsy findings corroborate law enforcement accounts that Mr. Higgins had gone into convulsions while officers searched a private jet that had been carrying the hip-hop star for drugs and guns.

Federal agents gave Mr. Higgins Narcan, a drug used to revive people thought to be overdosing on opioids, but he died within a couple of hours at Advocate Christ Medical Center in Oak Lawn, Ill., the authorities said.