An assassination attempt left a Democratic congresswoman in critical condition, killed Arizona's chief federal judge and five other people and forced Americans to question the toxic legacy of their divisive politics.

Representative Gabrielle Giffords, a three-term lawmaker, was among 13 people wounded in the shooting on Saturday morning at a public event in Tucson. The gunman was in custody.

A shaken President Barack Obama called the attack “a tragedy for our entire country”.

Ms. Giffords (40) is a moderate Democrat who narrowly won re-election in November against a Tea Party candidate who sought to throw her from office over her support of the healthcare law.

Event volunteer Alex Villec said the gunman asked to see the lawmaker but was told to wait his turn. He returned minutes later.

Firing a semiautomatic weapon, the gunman targeted Ms. Giffords as she met with constituents outside a busy Tucson supermarket, shooting her in the head. He also fired at her district director and shot indiscriminately at the crowd, said Mark Kimble, a communications staffer for Ms. Giffords.

“He was not more than three or four feet from the congresswoman,” Mr. Kimble said, describing the scene as “just complete chaos, people screaming, crying”.

Pima County Sheriff Clarence Dupnik said the rampage ended only after two people tackled the gunman. He was identified by people familiar with the investigation as Jared Loughner (22).

His motivation was not immediately known, but Mr. Dupnik described him as mentally unstable.

The sheriff blamed the vitriolic political rhetoric that has consumed the country, especially Arizona. Ms. Giffords expressed similar concern, even before the shooting. In an interview after her office was vandalised last year, she referred to the animosity against her by conservatives.

The shooting cast a pall over the Capitol as politicians of all stripes denounced the attack as a horrific. Capitol police asked members of Congress to be more vigilant about security in the wake of the shooting.

Doctors were optimistic about Ms. Giffords surviving as she was responding to commands from doctors. “With guarded optimism, I hope she will survive, but this is a very devastating wound,” said Dr. Richard Carmona, the former surgeon-general who lives in Tucson.

An uncle of Christina, the nine-year-old victim, told the Arizona Republic that a neighbour was going to the event and invited her along because she had just been elected to the student council.

The suspect Mr. Loughner was described by a former classmate as a loner, and the Army said he tried to enlist in December 2008 but was rejected for reasons not disclosed.

Federal law enforcement officials were poring over a MySpace page that included a mysterious “Goodbye friends” message published hours before the shooting and exhorted his friends to “Please don't be mad at me.”

In one of several YouTube videos, Mr. Loughner described inventing a new U.S. currency and complained about the illiteracy rate among people living in Ms. Giffords' congressional district in Arizona.

Ms. Giffords was first elected to Congress amid a wave of Democratic victories in the 2006 election, and has been mentioned as a possible Senate candidate in 2012 and a gubernatorial prospect in 2014. In 2007, she married astronaut Mark E. Kelly, who has piloted space shuttles Endeavour and Discovery. Mr. Kelly is training to be the next commander of the space shuttle mission slated for April and his brother is currently serving aboard the International Space Station, officials said. — AP