BOULDER, Colo. (AP) — A man accused of a mass shooting at a Colorado supermarket in 2021 pleaded not guilty by reason of insanity Tuesday as a judge ruled the case can move to a trial following testimony giving new details of how he killed most of the 10 victims in just over a minute using a gun with a high-capacity magazine.

Attorneys for Ahmad Al Aliwi Alissa entered the plea before District Court Judge Ingrid Bakke in Boulder. The plea means Alissa’s attorneys are claiming mental illness prevented him from understanding right from wrong on March 22, 2021, the day of the attack.

The hearing marked the first time prosecutors have spoken publicly about what happened at the crowded store in the college town of Boulder in the more than two years since the shooting, with the case stalled for much of the time after the suspect was deemed mentally incompetent.

New revelations Tuesday included that the suspect researched how to carry out a mass shooting by keeping notes on his iPhone for months beforehand about guns and how to move and shoot people. An investigator said he targeted moving people and kept shooting them until they were dead and had six high-capacity magazines, which are illegal to possess in Colorado.

“This defendant came armed and ready to kill as many innocent defenseless and unarmed people as quickly as he could,” Prosecutor Michael Dougherty said. “He killed eight of them within 69 seconds. He was able to do that because of the large capacity magazines.”

The 24-year-old defendant was recently deemed competent to stand trial after being forcibly medicated so that he could understand the proceedings. Competency is a separate legal issue than sanity and focuses on Alissa’s mental condition now, rather than when the shooting occurred.

Clad in an orange and white striped jail uniform, Alissa looked down in court and at times at the judge as she advised him of his rights before his plea was entered. If successful, the plea could allow Alissa, who has been diagnosed with schizophrenia, to avoid prison and instead be committed indefinitely to the state mental hospital.

The perpetrator of a 2012 mass shooting at an Aurora, Colorado, movie theater also pleaded not guilty by reason of insanity. But jurors in that case rejected the plea and sentenced defendant James Holmes to life in prison for the murders of 12 people.

Alissa is charged with 10 counts of murder, 15 counts of attempted murder and other offenses in the shooting in Boulder, a college town about 30 miles (50 kilometers) northwest of Denver. Neither his attorneys nor anyone else has disputed he was the gunman in the attack.

Bakke ruled Tuesday that the case could go to trial after determining there was sufficient evidence to proceed against Alissa. She ordered that experts conduct a sanity evaluation by Jan. 8 and tentatively scheduled a trial for August.

Boulder Police Detective Sarah Cantu gave key testimony Tuesday, describing how the gunman began firing as soon as he got out of his car in the store parking lot. She said Alissa first shot into the passenger side of a van parked beside him and then through its windshield, killing Neven Stanisic. Stanisic had just finished repairing a coffee machine at the Starbucks in the store.

Front end manager Rikki Olds was shot near the store entrance as Alissa entered, with only the length of Alissa’s rifle separating them, according to Cantu. There was no time for her to run or hide, the detective testified.

Cantu said the gunman targeted individuals who were moving and kept firing at them until they were dead, killing most of his victims within 69 seconds of beginning the attack. At one point he raised his rifle at a man who continued to shop, apparently unaware of the gunfire. But instead of firing, Cantu said, Alissa continued searching for victims and shot Suzanne Fountain, 59, when he saw her apparently leaving a hiding spot in another aisle.

“He found moving targets, pursued them and shot them until they stopped moving,” Cantu said.

Some relatives of the victims wiped back tears as they watched the hearing in an area of the court reserved for families.

Alissa is accused of killing nine shoppers and workers inside and outside the store as well as Officer Eric Talley, a father of seven and one of the first three police officers who entered the store. All but Olds were shot multiple times and everyone who was shot was killed, Cantu testified.

Authorities have not determined a motive for the attack, Cantu said. But a forensic psychologist testified in September that the 24-year-old Alissa bought firearms to carry out a mass shooting and indicated “there was some intention to commit suicide by cop.” Authorities have said Alissa used a legally purchased AR-556 pistol, which resembles a rifle.

Besides taking notes about how to shoot moving people, Alissa also researched how to make a rifle fully automatic, Cantu said.

Alissa was arrested in the store after being shot by a police officer, part of a second wave of law enforcement that entered after Talley was killed.

Outside court, Olds’ uncle, Robert Olds, said it stung to learn Tuesday that she was killed at such close range. He attended Tuesday’s hearing with his mother, Jeanette Olds, who had raised Rikki.

Robert Olds said part of him wishes Alissa had been killed.

“But the other half of me wishes that and hopes that at the end of this we find out the motive of why he did this,” he said.

___

Associated Press reporter Matthew Brown contributed from Billings, Montana.