Tucson, Arizona (CNN) -- Jared Lee Loughner, the alleged gunman in last year's mass shooting outside an Arizona supermarket in Tucson that killed six people and wounded then-U.S. Rep. Gabrielle Giffords, pleaded guilty Tuesday to 19 charges in exchange for the government not seeking the death penalty.
Under the plea deal, Loughner will be sentenced to life in prison with no eligibility for parole, federal prosecutors said. His sentencing is scheduled for November 15, prosecutors said.
In court, Loughner also waived his right to pursue an insanity defense.
"My name is Jared Lee Loughner," the defendant told the court when he held up his right hand under oath.
Loughner calmly told the court he understood his guilty plea. "Yes, that is correct," he said.
"I'm 23 years old," he told the court. "I attended college for five years at a community college."
Earlier Tuesday, Judge Larry Alan Burns found Loughner competent to stand trial in a federal court in Tucson.
"He's a different person in appearance and affect," the judge said about Loughner, who was present in the courtroom. "He's tracking today. He appears to assist his lawyers. Court's own observations are that there's no question he understands what's happening today."
Loughner had been facing more than 50 federal charges, and the remaining offenses will be dropped in exchange for the guilty pleas if Loughner is sentenced within the terms of the plea agreement, according to the written agreement filed in court.
Under the pleas, Loughner admitted guilt in the attempted assassination of Giffords and the murders of federal employees U.S. District Court Chief Judge John M. Roll, 63, and congressional aide Gabriel M. Zimmerman, 30, prosecutors said.
Loughner also pleaded guilty to the attempted murders of federal employees and congressional aides Ronald S. Barber, 65, and Pamela K. Simon, 63, prosecutors said.
Loughner also admitted causing the deaths of Christina-Taylor Green, age 9; Dorothy "Dot" J. Morris, 76; Phyllis C. Schneck, 79; and Dorwan C. Stoddard, 76, prosecutors said.
Loughner admitted injuring with a Glock pistol 10 persons participating at an activity provided by the U.S. government and creating a grave risk of death to 13 more persons, prosecutors said.
Prosecutors agreed to a plea deal -- and not to seek the death penalty -- after taking into account Loughner's history of mental illness and the views of victims and their families.
"It is my hope that this decision will allow the Tucson community, and the nation, to continue the healing process free of what would likely be extended trial and pre-trial proceedings that would not have a certain outcome," U.S. Attorney General Eric Holder said in a statement.
U.S. Attorney John S. Leonardo in Arizona added: "Given the defendant's history of significant mental illness, this plea agreement, which requires the defendant to spend the remainder of his natural life in prison, with no possibility of parole, is a just and appropriate resolution of this case."
Walking with a bit of a slouch, Loughner cast a sneer at the packed gallery when he entered the courtroom. During the guilty plea proceedings, the gallery was quiet, with some people sniffing and wiping away tears.
An order from the court indicating the planned change of pleas was released Monday.
Loughner earlier had pleaded not guilty to the charges against him, including murder and attempted murder.
The January 8, 2011, attack killed six people and wounded 13 others, including Giffords, who was holding a meet-and-greet event with constituents.
Giffords, who was shot in the head, stepped down from her position in Congress in January 2012 to focus on her recovery. Ron Barber, an aide also wounded in the attack, now holds the seat.
Giffords' husband, Mark Kelly, said in a statement Tuesday that he and his wife are satisfied with the agreement.
"The pain and loss caused by the events of January 8, 2011 are incalculable," Kelly said. "Avoiding a trial will allow us -- and we hope the whole Southern Arizona community -- to continue with our recovery and move forward with our lives."
Susan Hileman, 58, who was wounded, said after the court proceedings that she was proud to be an American.
"This is the system doing its best. It's not a perfect solution," Hileman told reporters. "This is the best that can be expected."
Loughner was facing the possibility of a death sentence if convicted.
Dr. Christina Pietz, a forensic psychologist, told the judge Tuesday that Loughner is "one of the worst" mentally ill patients she's ever seen.
But she continued, adding that Loughner has shown improvement and he's no longer in restraints. "He is competent to proceed," Pietz told the court.
He's no longer hearing voices, and he has no difficulty in understanding, Pietz said. Loughner is rational and able to consult with his attorneys, she said.
Loughner also understands that he will never leave prison and has told Pietz: "I'm 23 years old, this is it. This is my life."
Loughner is worried that he will be harmed by other inmates, but Pietz said she thinks Loughner would be all right in the general prison population.
Loughner, however, is still on suicide watch, Pietz said.
Pietz met Loughner in March 2011 and determined he had schizophrenia and wasn't competent to participate in court proceedings. She was the first doctor to diagnose him with a psychotic disease, Pietz said.
Loughner was disappointed and upset upon hearing the diagnosis, Pietz said.
Loughner said he wished he would have taken medication and that things might have been different.
He started taking medication for the first time on June 21, 2011, and over time, he expressed remorse about what he did, Pietz testified.
By July 9, 2011, Loughner expressed regret and "assassination remorse," Pietz said.
Loughner told Pietz that he was especially sad about the child killed in the shooting -- Christina Taylor Green, age 9, who was remembered nationally because she was born on September 11, 2001.
Loughner also spoke with Pietz about Giffords. Pietz testified that Loughner told her: "I know she's alive" and "there's no way she survived a shot to the head." Loughner said he feels like he set out to do the shooting and failed, Pietz said.
Loughner said if this is true, "Jared is a failure," according to Pietz.
In discussion with prison officials, Loughner has said, "I'll never get out," Pietz testified.
Loughner likes his prison jobs and he gets paid for them, which is important for him, Pietz said. The work makes him feel proud to do well in something, Pietz said.
Pietz recounted Loughner's teenage years, saying that he appeared normal until age 16.
Then he showed symptoms of depression in 2006, and his girlfriend broke up with him and a friend died, Pietz said.
Loughner sought treatment and was diagnosed with depression, Pietz said.
He saw a psychiatrist again after he was caught drunk at school, Pietz said. According to records, he didn't take his anti-depression medication, Pietz said.
In high school, he began hearing voices and yelling out things in the classroom -- behaviors that are symptoms of schizophrenia, Pietz said. He wrote nonsensical things on the chalkboard, showed a disorganized thought process, and became obsessed with the Constitution, Pietz said. Friends feared he would commit suicide, Pietz said.
Loughner became ostracized in high school, but at that point, there were no signs he would hurt anyone, Pietz said.
Loughner's mental condition has been central to much of the related court proceedings since the shooting.
In February, a federal judge ruled Loughner could receive medical treatment for another four months. A psychologist found "measurable progress" in the suspect's condition.
The medical treatment plan for Loughner was aimed at improving his mental state so he would be competent to stand trial.
Loughner was declared incompetent to stand trial in May 2011 after an initial evaluation term at a federal mental hospital in Springfield, Missouri.
In July 2011, what officials described as bizarre and suicidal actions by Loughner while in custody pushed a federal appeals panel to allow authorities to force the defendant to take anti-psychotic medication.
Prosecutors said then that Loughner had been deteriorating: He displayed screaming and crying fits that lasted hours, harmed himself and made claims that the radio was inserting thoughts into his head.
His attorneys consistently fought court rulings that Loughner continue his treatment at the hospital.
In November, defense attorney Ellis Johnston argued before a different federal judge that the side effects of the psychotropic drugs his client had been receiving during his court-ordered treatment may interfere with Loughner's ability to work with his attorneys.
But Assistant U.S. Attorney Christina Cabanillas said that Loughner "could revert to being a danger to himself" if the medication were halted.
Court documents released a few days after the shooting showed that investigators found a letter from Giffords in a safe at the house where Loughner lived with his parents, thanking him for attending a 2007 event.
"Also recovered in the safe was an envelope with handwriting on the envelope stating 'I planned ahead,' and 'my assassination' and the name 'Giffords,' along with what appears to be Loughner's signature," the affidavit stated.
CNN's Kyung Lah and Michael Cary, both in Arizona, and Bill Mears contributed to this report.