DENVER — In an emotional end to the court drama that has preoccupied Colorado, Judge Carlos A. Samour Jr. on Wednesday issued 12 life sentences in prison to James E. Holmes, who fatally shot 12 people in a movie theater in the Denver suburb of Aurora three years ago and wounded 70 others. The judge also imposed 3,318 years in prison on Mr. Holmes for his nonlethal crimes, including attempted murder.

“Get the defendant out of my courtroom,” Judge Samour said from the bench before Mr. Holmes, wearing a red prison suit, walked out of Courtroom 201 for the last time.

This month, a jury had elected to sentence Mr. Holmes to life in prison rather than the death penalty, which prosecutors had sought. On Wednesday, it was up to the judge to decide the penalty for Mr. Holmes’s nonlethal crimes. Later, the Colorado Corrections Department will evaluate him and decide which prison is most fitting.

Before reading the sentence, Judge Samour spent more than an hour delivering an impassioned speech to the crowded gallery, defending the justice system to victims’ families and others who had said that they felt Mr. Holmes had prevailed because his life had been spared.