The prosecutor in the Minnesota county where Prince died has said that no criminal charges will be filed in the musician’s death, effectively ending the state’s two-year investigation into how the artist obtained the powerful opiate that killed him.

Associated Press reports that the announcement by Mark Metz, the Carver county district attorney, came just hours after documents revealed that a doctor who was accused of illegally prescribing prescription painkillers for use by Prince had agreed to pay $30,000 to settle a federal civil violation.

Prince died two years ago at the age of 57

Prosecutors alleged Dr Michael Todd Schulenberg wrote a prescription for an oxycodone-based opioid in the name of Prince’s bodyguard, intending it to go Prince.

Metz said the evidence shows Prince thought he was taking a prescription opioid, Vicodin, not the more potent fentanyl. He said there was no evidence any person associated with Prince knew he possessed any counterfeit pill containing fentanyl.

Prince was 57 when he was found alone and unresponsive at his Paisley Park studio complex on 21 April 2016. His death sparked a global outpouring of grief, and prompted a joint investigation by Carver County and federal authorities.