A Belfast man who fatally shot a woman and seriously wounded her son with a shotgun blast last summer has pleaded guilty to murder and related charges as part of a plea agreement in which he will be sentenced to 50 years in prison.

Todd Gilday, 44, was due to stand trial next month for killing Lynn Arsenault and seriously injuring Mathew Day. Instead, on Monday in Waldo County Superior Court in Belfast, he changed his plea to guilty from his previous plea of not guilty by reason of insanity.

Gilday said little at the hearing before Justice Robert Murray, other than to answer questions about his state of mind and to enter guilty pleas to charges of murder, attempted murder and elevated aggravated assault, according to one of his attorneys, Jeremy Pratt.

“We had had extensive plea negotiations regarding the case over the last few weeks and months,” Pratt said. “I think the state’s case was very strong and Mr. Gilday felt a great deal of remorse for his actions and wanted to take responsibility for them without a trial.”

Under terms of the plea agreement, Gilday will be sentenced next month to 50 years for murdering Arsenault, who was 55 at the time, and 15 years for the attack on Day, to be served at the same time as the murder sentence.

Pratt said Gilday did not plan to speak at his sentencing hearing on Aug. 20, but planned instead to submit a letter to the court expressing his regrets.

The prosecutor in the case, Assistant Attorney General Leane Zainea, did not immediately return a phone message regarding the case against Gilday.

No clear motive has ever been disclosed for why Gilday went to 162 Waldo Ave. in Belfast, the home owned by Arsenault, last Aug. 28 and fired birdshot from a 12-gauge shotgun into Day’s arm and stomach, and into his mother’s shoulder and chest.

Day, now 23, lay bleeding on the kitchen floor but was able to identify Gilday as the gunman. He told police he didn’t know why Gilday had shot them, according to an affidavit filed in court last year by Maine State Police Detective Dean Jackson.

Half an hour before the shooting, Gilday had been at his home at 30A Springbrook Drive in Belfast, dressed in a bathrobe and crying at one point when an acquaintance, Samantha Ladd, stopped to visit him.

Gilday told her he was going to “shoot some people tonight,” but answered only “I don’t care” when Ladd asked whom he was going to shoot, according to an account she gave to police.

Gilday has been in custody since the day after the shootings, when police arrested him at Penobscot Bay Medical Center in Rockport. He had been admitted to the center’s unit for psychiatric and addiction patients on Aug. 29 after telling the staff that he was a drug addict who “had taken a large amount of opiates the night before,” Jackson said in the affidavit.

A possible motive for the shooting could hinge on Gilday’s relationship with Day’s girlfriend, Misty Linscott, and her mother, Linda Linscott. Gilday drove Misty Linscott to report for a jail term earlier in the day before the shooting.

Misty Linscott told Jackson that Gilday was just a friend who would give her rides, that they had done drugs together but that they were not in an intimate relationship, Jackson said in his affidavit.

“She described Gilday as being a little strange. He would stare at her and make inappropriate comments to her in front of Day,” Jackson wrote.

Misty Linscott has declined several requests for interviews.

Linda Linscott told police that Misty had lost custody of her children to her, and that Gilday had become involved, helping Misty steal a camera from her with pictures that could be used to influence custody arguments, the affidavit says.

“According to Linda Linscott, Todd Gilday was upset because he seemed to think that she was trying to help the state take Misty’s kids away from her,” Jackson wrote.

The affidavit also provides detailed accounts from Day’s friend Jonathan Riley, who was in Arsenault’s house when Gilday fired the shots, and from a police interview with Day as he recovered at Eastern Maine Medical Center in Bangor.

Day told police that he considered Gilday a nice guy but “a bit odd.” He said he and Gilday acquired drugs for each other and Gilday gave him rides.

Gilday texted Day before the shooting, asking to talk to him about Misty and Linda Linscott’s custody dispute. Day agreed, but saw, when Gilday arrived at the house, that he had a shotgun with him.

“Mathew closed the door and tried to lock it, but Gilday shot through the door,” Jackson said in the affidavit.

Riley told police that he hid behind the couch in the living room but saw Gilday shoot Day, then Day’s mother as she came out of her bedroom, where she had been sleeping.

“Riley heard Mathew Day pleading with Todd Gilday not to kill them. Todd Gilday responded, ‘I’m going to kill everyone,'” Jackson wrote.

After the shootings, Gilday left the house and drove away, apparently without seeing Riley or firing another shot. Police found the shotgun on Sept. 1 in Levenseller Pond at the Searsmont-Lincolnville town line and traced it back to a Wal-Mart in Bangor, where Gilday bought it in 2012, according to the affidavit.