TUCSON, Ariz. (AP) — Jared Loughner sat looking relaxed and attentive in a packed courtroom as he pleaded guilty to a deadly shooting rampage in an agreement with prosecutors that will send him to prison for life. He even cracked a smile when a court-appointed psychologist talked about the special bond that he formed with a prison guard.
His hair closely cropped, Loughner was not the smiling, bald-headed suspect captured in a mug shot soon after the January 2011 shooting. Six people had died and 13 others were wounded, including his intended target, then-Rep. Gabrielle Giffords.
He was not the man who rocked back and forth in court in May 2011 before blurting out, "Thank you for the free kill. She died in front of me. Your cheesiness."
The changes in Loughner's behavior while being treated and medicated at a federal prison in Springfield, Mo., led a judge to declare the 23-year-old competent Tuesday. U.S. District Judge Larry Burns gave his blessings to a plea agreement that spares prosecutors and victims a potentially lengthy trial and appeal and allows Loughner to escape the death penalty.
The judge called Loughner "a different person in his appearance and his affect than the first time I laid eyes on him."
Loughner didn't talk to his attorneys or look around the courtroom during the two-hour hearing. He folded his arms in front of him and focused his gaze on the psychologist and judge as they did most of the talking.
His parents sat silently in the back row, but sobbed and embraced after their son left looking frail on his feet.
The prosecution and defense seemed eager to seal the agreement, a departure from previous marathon hearings. Judy Clarke, Loughner's lead attorney, gently guided him through a copy of the plea agreement on the table as the judge went through it. She declined to question the psychologist.
Loughner pleaded guilty to 19 counts, including attempted assassination of a member of Congress, murder and attempted murder of federal employees, and causing death and injury at a federally provided activity. As part of the agreement, the federal government dropped 30 other counts.
"I plead guilty," he said in a low voice after the judge read each charge.
The agreement calls for a sentence of seven consecutive life terms followed by 140 years in prison, according to federal officials. Loughner, who will be sentenced Nov. 15, is ineligible for parole.
The agreement provided some relief to many victims and their families who filled about half the courtroom, some shedding tears as the judge recited names of the victims. Ron Barber, a former Giffords staffer who was wounded in the attack and later won election to her seat when she stepped down, watched from the front row.
"I truly believe that justice was done today. It is important to me that this individual never again is in a position in which he can cause harm to anyone else," Barber said outside the courthouse.
Gifford also welcomed the deal, saying in a statement with her husband, Mark Kelly: "The pain and loss caused by the events of Jan. 8, 2011, are incalculable. Avoiding a trial will allow us — and we hope the whole Southern Arizona community — to continue with our recovery."
Giffords has undergone intensive therapy and made dramatic progress recovering from her brain injury, yet her movements and speech are still halting.
Susan Hileman, who was wounded in the attack, said nothing would return her life to what it was before and that she regretted Loughner didn't get treatment earlier. Hileman had taken 9-year-old Christina-Taylor Green to the Giffords event outside a supermarket, where the girl was killed in the shooting.
"This is so sad — a 23-year-old who's going to spend the rest of his life in a box. I feel empty. What I want, I can't have," she said. "This is closing the barn door after the horses left. This is too late."
Pietz, the court-appointed psychologist, testified that Loughner appeared to be a normal child and average student until he was 16, when a girlfriend broke up with him and a friend's father died. He was diagnosed with depression and landed at an alternative education program at Pima Community College his senior year after he showed up drunk for school one day.
He was enrolled at the Tucson college until September 2010, alarming his parents and friends with his increasingly erratic behavior, Pietz said. He became obsessed with the Constitution, wrote jumbled words on the chalkboard and a final exam, and yelled incoherently in class.
Loughner's parents told Pietz that their son once asked them if they heard voices. They worried that he would take his life.
Pietz recounted turning points in Loughner's recovery in prison: regular exercise; counseling sessions with three other inmates; and prison jobs rolling towels, T-shirts and socks, and stamping envelopes. He has been forcibly medicated for more than a year after being diagnosed with schizophrenia.
"He loves his jobs," she said.
Pietz said she found him competent in an April report, and added: "I think he's improved even more."
Clarke also avoided the death penalty for other high-profile clients, such as "Unabomber" Ted Kaczynski and Eric Rudolph, who bombed abortion clinics in the late 1990s and Atlanta's Olympic park in 1996.
David Bruck, a close friend of Clarke since law school, said that it was a question whether Loughner could endure the stress of a trial. But, he said, the defense had no reason to challenge the finding.
"To say what someone else's mental capacity is always iffy. If the prosecution was still seeking the death penalty, the question of competency would have been raised by the defense," Bruck said.
Christie reported from Phoenix. Associated Press writer Carson Walker contributed to this report.