BOISE -- A 26-year-old charged with plunging a kitchen knife into his roommate's abdomen, fatally wounding him, accepted a plea deal Tuesday.

Michael Ryan Downs admitted to second-degree murder as part of the agreement, which reduced the charge down from first-degree murder and dismissed additional drug charges.

The stabbing happened Jan. 5 at Downs' parents' home in the Boise Foothills where both the defendant and 26-year-old victim Daniel Ridgeway lived.

Downs told Judge Patrick Owen that he had been using methamphetamine and was gripped in a drug-induced "psychosis" when he attacked Ridgeway, his friend since junior high.

MORE: Murder suspect's parents recount bizarre behavior before stabbing

Downs said he had been experiencing "very irrational beliefs about the world and about Dan in particular."

"The main one was that he had raped my sister, which was not true," he said.

Family members of the defendant previously testified Downs had been acting strangely and had become preoccupied with the idea that Ridgeway was a sexual predator who planned to harm his family. Downs' father said he later learned his son had also stopped taking medication for his bipolar disorder around that time.

After Downs punched Ridgeway during an argument, the defendant's alarmed family took him to an emergency room, where he told a doctor about his plan to kill Ridgeway. Despite the threat, Downs was released from St. Luke's days later: no psychiatric facility beds were available, and Downs seemed to be back to his normal self, according to testimony.

He attacked Ridgeway the next morning in the hallway outside his parents' bedroom.

"I stabbed him with a large kitchen knife while under the influence of meth," Downs told the judge Tuesday.

RELATED: Boise stabbing suspect pleads not guilty to murder

The knife punctured Ridgeway's liver, and he spent months in the hospital battling infections, gangrene and blood clots before dying from complications of the wound March 26. The death was ruled a homicide.

As part of the plea deal, prosecutors agreed to ask the judge to hand down a 40 year sentence, with 20 years before Downs would be eligible for parole. The judge is not bound by their recommendation, however, and can elect to put Downs behind bars for up to a life sentence.

Sentencing is set for Jan. 6, 2017.