DEDHAM, Mass. (AP) — The prosecutor in the murder trial of a man charged with killing a Massachusetts police officer and an innocent bystander nearly five years ago told jurors in opening statements on Thursday that the suspect acted with deliberation when he used the officer’s own gun to shoot him multiple times.

The defense, however, described a defendant who has spent years struggling with mental illness made worse by frequent marijuana use, who wasn’t taking his medications, and who in the days before the killings was having a dispute with his longtime on-and-off girlfriend.

Emanuel Lopes, 25, faces 11 charges, including two counts of murder, in connection with the killings of Weymouth police Sgt. Michael Chesna, 42, a veteran and married father of two, and bystander Vera Adams, a 77-year-old widow, on July 15, 2018. He has pleaded not guilty.

“We will prove beyond a reasonable doubt that Lopes shot and killed Sgt. Michael Chesna, shot and killed Vera Adams, and shot at” two other officers who responded to the scene with the intent to kill them, prosecutor Greg Connor told the jurors in Norfolk Superior Court.

Because of the intense media coverage the killings received in Weymouth, a suburb south of Boston, the jury was selected in Worcester County to ensure impartiality.

Lopes was fleeing the scene of a minor car crash and Chesna was investigating when their lives intersected, authorities have said.

Lopes threw a large rock that struck the officer in the head and knocked him to the ground unconscious. The suspect then grabbed the officer’s gun and shot him multiple times, Connor said.

As he fled, Lopes shot Adams, who was on her porch. He still had Chesna’s service weapon when he was caught minutes later, and it was out of ammunition, authorities said.

Defense attorney Larry Tipton said Lopes started experiencing mental health problems as a teenager, described him hearing voices, harming himself, and getting committed to the hospital multiple times.

“Fifteen, 20 clinicians diagnosed a young man with major mental illness, sometimes not sure what the major mental illness was,” Tipton said.

Lopes’ friends described his behavior as “ranting, kind of like it’s Manny being Manny, talking about government conspiracies, people being Martians, monkeys, illuminati, talking about being in fear, danger,” the defense attorney said.

With dozens of potential witnesses, the trial could last weeks.

If convicted, Lopes faces life in prison. If found not guilty by reason of mental defect, he could be sent to a mental health facility for an indefinite period of time.