A Los Angeles man pleaded guilty Monday to supplying fentanyl-laced oxycodone that killed rapper Mac Miller, according to documents obtained by TMZ.

Stephen A. Walter, 48, and his attorney signed an agreement Friday in the central district of California that Walter distributed fentanyl to others and that it was taken by Miller, who died on Sept. 7, 2018.

Walter was one of three men charged in connection with Miller's overdose death. USA Today cited Walter's attorney who said that Walter instructed Ryan M. Reavis, 36, to distribute the fentanyl that was presented as oxycodone pills to Miller's dealer, Cameron J. Pettit, 28.

Pettit and Reavis pleaded not guilty to all charges.

Court documents cite Mac Miller as "M.M." Miller's real name is Malcolm James McCormick.

"Defendant knew that the pills that he directed Reavis to give to Pettit contained fentanyl or some other federally controlled substance," the agreement read. "M.M. would not have died from an overdose but for the fentanyl contained in the pills that M.M. had received from Pettit on September 4, 2018."

Walter faces up to 21 years in prison. He accepted a 17-year prison sentence. Walter was already on supervised release from a previous drug offense.

Miller was 26 at the time of his death. His assistant found him in bed in a “praying position,” according to the toxicology report. The Los Angeles County Medical Examiner-Coroner determined that Miller died of mixed drug toxicity that involved fentanyl, cocaine and alcohol.

Miller had openly spoken about his struggles with drug addiction before his death.