Jared Lee Loughner pleaded guilty Tuesday to killing six people and wounding 13 others, including then-Arizona Congresswoman Gabrielle Giffords, in a January 2011 shooting rampage.

Loughner, 23, entered the guilty plea shortly after a federal judge found him competent to understand the gravity of the charges against him.

Loughner will be spared the death penalty and sentenced to life in prison with no possibility of parole.

Giffords, Loughner’s intended target, welcomed the plea agreement, saying it allows victims to avoid a lengthy trial and move on with their lives.

“The pain and loss caused by the events of Jan. 8, 2011, are incalculable," Giffords said in a joint statement with her husband, Mark Kelly. "Avoiding a trial will allow us -- and we hope the whole Southern Arizona community -- to continue with our recovery."

Mental health experts who assessed Loughner concluded that he suffers from schizophrenia and he was forcibly medicated with anti-psychotic drugs in prison for more than a year.

On Tuesday, court-appointed psychologist Christina Pietz told Judge Larry A. Burns that Loughner has "one of the worst" cases of mental illness she has ever seen.

However, she said Loughner’s condition has improved over time.

Burns ruled Tuesday that medication has rendered Loughner competent to admit to the crimes he was accused of.

The judge said observing Loughner, who sat quietly throughout the hearing, left "no question that he understands what's happening today."

Loughner’s parents cried and hugged each other in court as some of the victims who attended looked on.

Loughner faced 49 federal charges in the shooting outside a Tuscon supermarket, where Giffords was meeting with constituents. She was shot in the head but survived, facing a long and painful rehabilitation.

Giffords stepped down from Congress to focus on her recovery. Ron Barber, one of her staffers who was also wounded in the attack, was elected to fill her position.

"I truly believe that justice was done today," Barber told reporters after the hearing. "It is important to me that this individual never again is in a position in which he can cause harm to anyone else."

Suzi Hileman, another wounded bystander, was emotional as she addressed the crowd outside court.

Hileman had taken her nine-year-old neighbour, Christina Taylor-Green, to Giffords’ “Congress on Your Corner” event so the child could meet the congresswoman.

Christina was fatally shot in the melee. Hileman survived three gunshot wounds.

“Today’s events make me very proud to be an American,” Hileman said after Loughner’s guilty plea.

“This was the system doing its best. It’s not the perfect solution. The perfect solution is one that we can’t have. What we want is not available to us. This is the best that can be expected.”

Some legal experts who have been following the case said it’s still possible for the state of Arizona to file its own charges against Loughner.

The prosecutor’s office declined to comment Tuesday, saying it did not have an active prosecution against Loughner.

With files from The Associated Press