BOSTON (AP) — A man accused of killing a Massachusetts police officer with the officer's own weapon as well as an innocent bystander pleaded not guilty Tuesday.

Twenty-year-old Emanuel Lopes was arraigned on charges including two counts of first-degree murder in front of a courtroom gallery packed with police officers.

Norfolk Assistant District Attorney Greg Connor described how Lopes struck Weymouth Officer Michael Chesna with a large rock Sunday morning, grabbed the officer's service weapon and shot him 10 times. Chesna was investigating reports of an erratic driver and car crash.

Authorities say Lopes then shot 77-year-old widow Vera Adams in the chest through the sliding glass door of her home. Lopes was later shot in the leg by police.

A court psychologist testified that Lopes disagreed with the homicide charges against him, but understood them. He was declared competent for arraignment.

Lopes' lawyer argues he is not mentally competent to stand trial, and asked that his client undergo a mental health evaluation at Bridgewater State Hospital due to a history of psychiatric admissions. The judge denied that request.

Lopes' mother in an affidavit seeking a restraining order on her son said she was "afraid" of him because of mental health and substance abuse issues.

He is due back in court Aug. 15 for a probable cause hearing. Quincy is approximately 10 miles (16 kilometers) south of Boston.

A wake for Chesna will be held on Thursday at St. Mary's Catholic church in Hanover, followed by a funeral mass at the church on Friday. Chesna will be buried in Blue Hill Cemetery in Braintree.

The Weymouth Police Department has set up a fund to benefit the Chesna family.

Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.