TUCSON — Jared L. Loughner was sentenced Thursday to seven consecutive terms of life in prison at a court hearing punctuated by raw emotion as former Representative Gabrielle Giffords and her husband, Mark E. Kelly, for the first time confronted the man who shot her in the head during a rampage last year that left 6 dead and 12 others wounded.

Ms. Giffords, her right arm in a sling, stared at Mr. Loughner as Mr. Kelly delivered his defiant remarks before a packed courtroom, from a dais a few feet from the defendant’s chair.

“By making death and producing tragedy, you sought to extinguish the beauty of life, to diminish potential, to strain love and to cancel ideas,” Mr. Kelly said. “You tried to create for all of us a world as dark and evil as your own. But remember it always: You failed.”

Mr. Loughner’s punishment — in addition to the life terms, he was sentenced to 140 years in prison — came as no surprise. It was a condition of the guilty plea he entered on Aug. 7, admitting to the shootings and bringing to an end a case that had prompted much soul-searching about mental health treatment and the country’s gun laws.