RANDOLPH (CBS) – Court documents allege that Justin Gaston, charged with killing his friend inside a Randolph home, was upset because he believed the victim had played a part in having him involuntarily committed to a mental facility. Gaston was the subject of a large manhunt that lasted for nearly 24 hours.

Gaston was arraigned Wednesday morning and ordered help without bail. His family — and the family of the man he allegedly killed — was in the courtroom.

READ MORE: Northeast Metro Tech Football Player Seriously Injured During Saturday Game

Police had described Gaston as armed and dangerous as they searched for him. He was captured Tuesday night in Lynn after about 20 hours on the run.

Justin Gaston is arraigned on March 6, 2019. (WBZ-TV)

He’d been on the loose since Monday night when he allegedly shot and killed Haki Sanders at his home on Petipas Lane in Randolph.

Court documents allege that Gaston believed Sanders and Gaston’s mother were the reason he was involuntarily put in a mental hospital in December. Gaston said his friends had stopped talking to him after his stay in the mental hospital.

READ MORE: Longtime Watertown Grocery Store Russo’s Officially Closes

According to prosecutors, the reason for Gaston was brought to the mental hospital for three days in December was that he was found acting erratically in New Hampshire.

Police investigate homicide in Randolph (WBZ-TV)

At one point during an argument at the Petipas Lane home, Gaston’s mother left the room. According to court documents, she heard Sanders say “You have a gun? You’re going to shoot me?”

She ran into the hallway and allegedly saw Gaston following Sanders, so she called 911. While on the phone with dispatchers, Gaston’s mother heard gunshots from inside the home.

Gaston got into a black SUV and drove off, leading to the manhunt. A SWAT team, state and local police closed in on Gaston around 4:30 p.m. on Tuesday. Police took him into custody without incident.

MORE NEWS: Boch Center Becomes 1st Performing Arts Center In Boston To Offer On-Site Rapid COVID Tests

Gaston is next scheduled to appear in court on April 2.