No criminal charges will be filed in the death of pop singer Prince, according to prosecutors in the Minnesota county where the artist lived before dying of a drug overdose in 2016.

Carver County attorney Mark Metz said the artist had died after accidentally taking counterfeit Vicodin pills that were laced with fentanyl – an illegal opioid more powerful than heroin. There was no evidence that anyone around the singer knew the pills were fake.

“Prince had no idea he was taking a counterfeit pill that could kill him,” Mr Metz said.

The announcement effectively ended a two-year investigation into how the singer obtained the drugs that lead to his death. He was found unconscious in an elevator at his Paisley Park home in April 2016, at the age of 57.

Investigators later found numerous pills around his home, some of which contained fentanyl. Experts examining his toxicology report called the concentration of fentanyl in his body “exceedingly high”.

A law enforcement official told the Associated Press that the federal investigation was now inactive, unless new information came forward.

Fans mourn Prince outside Paisley Park Show all 15 1 /15 Fans mourn Prince outside Paisley Park Fans mourn Prince outside Paisley Park CHANHASSEN, MN - MAY 2: Tributes and memorials dedicated to Prince on the fence that surrounds Paisley Park on May 2, 2016 in Chaska, Minnesota. Prince died on April 21, 2016 at his Paisley Park compound at the age of 57. As a will has not been found, court proceedings have started to decide how his assets should be divided. (Photo by Adam Bettcher/Getty Images) Getty Images Fans mourn Prince outside Paisley Park MINNEAPOLIS, MN - APRIL 22: Jacqueline Pruitt wipes away a tear after leaving flowers at a memorial to Prince outside the First Avenue nightclub on April 22, 2016 in Minneapolis, Minnesota. Prince, 57, was pronounced dead shortly after being found unresponsive yesterday at his Paisley Park Studio in Chanhassen, Minnesota near Minneapolis. (Photo by Scott Olson/Getty Images) Getty Images Fans mourn Prince outside Paisley Park CHANHASSEN, MN - MAY 2: Tributes and memorials dedicated to Prince on the fence that surrounds Paisley Park on May 2, 2016 in Chaska, Minnesota. Prince died on April 21, 2016 at his Paisley Park compound at the age of 57. As a will has not been found, court proceedings have started to decide how his assets should be divided. (Photo by Adam Bettcher/Getty Images) Getty Images Fans mourn Prince outside Paisley Park CHANHASSEN, MN - APRIL 24: People walk past the memorial outside Paisley Park on April 24, 2016 in Chanhassen, Minnesota. Prince died on April 21 at his Paisley Park compound at the age of 57. (Photo by Jules Ameel/Getty Images) Getty Images Fans mourn Prince outside Paisley Park CHANHASSEN, MN - APRIL 23: Mementos left by fans are attached to the fence which surrounds Paisley Park, the home and studio of Prince, on April 23, 2016 in Chanhassen, Minnesota. Prince, 57, was pronounced dead shortly after being found unresponsive April 21 in an elevator at Paisley Park. (Photo by Scott Olson/Getty Images) Getty Images Fans mourn Prince outside Paisley Park CHANHASSEN, MN - APRIL 23: Music fans visit a memorial created outside Paisley Park, the home and studio of Prince, on April 23, 2016 in Chanhassen, Minnesota. Prince, 57, was pronounced dead shortly after being found unresponsive in an elevator April 21 at Paisley Park. (Photo by Scott Olson/Getty Images) Getty Images Fans mourn Prince outside Paisley Park Getty Fans mourn Prince outside Paisley Park Getty Fans mourn Prince outside Paisley Park Getty Fans mourn Prince outside Paisley Park CHANHASSEN, MN - APRIL 22: Music fans visit a memorial outside Paisley Park, the home and studio of Prince, on April 22, 2016 in Chanhassen, Minnesota. Prince, 57, was pronounced dead shortly after being found unresponsive yesterday at Paisley Park. (Photo by Scott Olson/Getty Images) Getty Images Fans mourn Prince outside Paisley Park People pay their respects outside the Paisley Park compound of music legend Prince in Minneapolis, Minnesota, on April 22, 2016. Prince, whose pioneering brand of danceable funk and virtuoso talents made him one of the most influential figures in music, died April 21, 2016, aged 57. There was no evidence of trauma on Prince's body when he was found unresponsive at his Minnesota compound, and his death is not thought to be a suicide, authorities said. / AFP / Mark Ralston (Photo credit should read MARK RALSTON/AFP/Getty Images) AFP/Getty Images Fans mourn Prince outside Paisley Park A Prince fans attachs flowers to a memorial wall as he pays his respects outside the Paisley Park compound in Minneapolis, Minnesota, on April 22, 2016. Prince died April 21, 2016. / AFP / Mark Ralston (Photo credit should read MARK RALSTON/AFP/Getty Images) AFP/Getty Images Fans mourn Prince outside Paisley Park Getty Fans mourn Prince outside Paisley Park MINNEAPOLIS, MN - APRIL 22: A photo of Prince is attached to the wall outside of the First Avenue nightclub where fans have created a memorial to the artist on April 22, 2016 in Minneapolis, Minnesota. Prince, 57, was pronounced dead shortly after being found unresponsive yesterday at his Paisley Park Studio in Chanhassen, Minnesota near Minneapolis. (Photo by Scott Olson/Getty Images) Getty Images Fans mourn Prince outside Paisley Park TOPSHOT - Messages left by fans outside the Paisley Park residential compound of music legend Prince in Minneapolis, Minnesota, on April 21, 2016. Emergency personnel tried and failed to revive music legend Prince, who died April 21, 2016, at age 57, after finding him slumped unresponsive in an elevator at his Paisley Park studios in Minnesota, the local sheriff said. / AFP / Mark Ralston (Photo credit should read MARK RALSTON/AFP/Getty Images) AFP/Getty Images

Prosecutors had previously accused Dr Michael Schulenberg, a Minnesota physician who had previously treated Prince, of prescribing the painkiller oxycodone for the singer under someone else’s name.

The doctor was not charged on Thursday, but agreed to pay $30,000 (£21,300) to settle a federal civil violation for “[prescribing] controlled substances in the name of an individual, knowing that the controlled substances were intended to be used by another individual”.

Mr Schulenberg did not admit liability as part of the agreement, and a letter sent to his attorneys says he is not the target of a criminal investigation.

Prince: Rare 'nothing compares 2 u' on BBC The One Show

Mr Schulenberg’s attorney, Amy Conners, said in a statement that the doctor denies prescribing opiates to any patient with the intention they be given to Prince.

“After he learned of Prince’s addiction, he immediately worked to refer Prince to a treatment facility and to transfer care to a chemical dependency specialist,” she said. “Dr Schulenberg has previously disclosed all information regarding his care and treatment of Prince to his employers, law enforcement, and regulatory authorities in the course of his complete cooperation with all related investigations.”