Image caption Jared Loughner has been forcibly medicated for schizophrenia

The man accused of shooting a US congresswoman in Arizona and killing six others has pleaded guilty after a judge found him mentally competent.

Last year, Jared Loughner's case was put on hold after experts said he had schizophrenia.

The plea deal spares Loughner, 23, from the death penalty, and he is expected to be sentenced to life in jail.

Former Arizona Representative Gabrielle Giffords was wounded in the January 2011 attack and has since left office.

Earlier on Tuesday she said she would be satisfied with Loughner's plea deal.

Her husband Mark Kelly wrote: "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."

Courtroom outburst

Under the terms of the deal, Loughner pleaded guilty to 19 criminal counts related to the deaths of six people and wounding of 13 more in the shooting rampage in Tucson, Arizona.

They including attempted assassination of a member of Congress, murder and attempted murder of federal employees.

Loughner appeared in court wearing a khaki jumpsuit, with his hair cut short. Witnesses say that, seated beside his lawyers, he appeared to pay attention to the proceedings.

When Judge Larry Burns asked the defendant if he understood the charges against him, Loughner replied: "Yes, I understand."

The judge said that seeing Loughner in court left no doubt that "he understands what's happening today".

Media playback is unsupported on your device Media caption Arizona shooting victim: 'There's a hole in the world'

Initially, Loughner had been charged with 49 criminal counts including first-degree murder.

Before Tuesday's hearing, Loughner had been forcibly medicated with psychotropic drugs for more than a year at a prison hospital in Springfield, Missouri.

A not-guilty plea was entered on his behalf last year.

Tuesday's proceedings were the fourth time he appeared in court for a judge to determine his mental competence.

In May 2011 Loughner was declared unfit to stand trial after he had an outburst in the courtroom, saying: "Thank you for the free kill. She died in front of me. Your cheesiness."

His stay in hospital was previously extended after a judge found that "measurable progress" had been made by those treating him.

Dr Christina Pietz, a forensic psychologist appointed by the court, testified on Tuesday that Loughner was "one of the worst" mentally ill patients she had seen.

She added that he had improved to the point where he was no longer hearing voices and could understand the proceedings, CNN reported.

'Justice was done'

Ms Giffords, a Democrat, was holding a regular constituency event at a supermarket when she was shot in the head at close range.

A federal judge and a nine-year-old girl were among the victims of the shooting.

Image caption Gabrielle Giffords was seen as a rising star within the Democratic Party before the shooting

Ms Giffords' seat is now occupied by Ron Barber, her former aide, who was also injured in the shooting. He is standing for re-election to a full two-year term in November.

"I truly believe that justice was done today," Mr Barber said 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."

Susan Hileman, who had accompanied the nine-year-old Christina-Taylor Green to the fateful meeting, said that while the plea was the best result she could have expected, it would not bring back Green or prevent similar shootings.

"This is a damaged young man who did terrible things, and we need to pay attention to one another," she said.

"There needs to be a concerted effort to intervene when you see something is not right."