A US judge has accepted a plea of not guilty by reason of insanity from James Holmes, accused of killing 12 people and wounding dozens in a Colorado theatre shooting last year.
Judge Carlos Samour accepted the plea after reading out a list of conditions, including that the 25-year-old agree to undergo a court-ordered "sanity examination.''
The tests, to determine if Holmes is fit to stand trial, will likely take months. Prosecutors say complex preparations he allegedly made before the shootings show that he knew exactly what he was doing and that it was wrong.
Holmes is accused of wounding another 70 people when he allegedly opened fire last July in a packed midnight screening of the Batman movie The Dark Knight Rises in the Colorado town of Aurora, outside Denver.
The trial judge initially entered a straight "not guilty'' plea on Holmes's behalf in March. Last month, Holmes tendered an insanity plea, but the judge said he would not yet formally accept it.
In court on Tuesday, the judge read out a five-page, 18-point advisement which defined the applicable test for insanity, and listed what was required of Holmes and his lawyers.
After reading the advisement, the judge asked Holmes if he had any questions, and the accused replied: "No.''
The judge ordered Holmes to be sent to the Colorado State Mental Institute in Pueblo, Colorado. He will likely be moved there from jail in a matter of weeks, and could stay there for a month or two.
The judge said there was "no doubt on the part of the defense attorneys as to Mr Holmes' ability to understand the proceedings.''
Witnesses said Holmes threw smoke bomb-type devices before opening fire in the theater with weapons including an AR-15 military-style rifle, a 12-gauge shotgun and a .40-caliber pistol.
Prosecutors are pursuing the death penalty in the case, in which Holmes faces 166 counts of capital murder and attempted murder.
The judge also ruled that a package sent by Holmes to a college psychiatrist who had been treating him, reported to contain a notebook which could include plans for the attack, could be turned over to prosecutors.
The package was addressed to Dr. Lynne Fenton and arrived at a University of Colorado mailing room three days after the attack. She has never seen it, and it has been held by a court clerk since last summer.
It will be turned over to prosecutors on Monday. They can then give it to psychiatrists who examine Holmes.
The case has been delayed in recent months amid legal wrangling. Last week the judge dismissed arguments that the western US state's laws on insanity and the death penalty violate the constitution.
In late March, defense lawyers filed an unexpected motion offering that Holmes would plead guilty in return for the prosecution not pressing for the death penalty, but agreeing to a sentence of life in prison without parole.
Prosecutors shot back within 24 hours, accusing the defense of trying to negotiate a plea deal in public, in violation of a gag order. They then said they would seek the death penalty.
Colorado currently has three convicted prisoners on death row but has not executed anyone since 1997.