Rep. Gabrielle Giffords of Arizona was shot in the head Saturday when an assailant opened fire outside a grocery store during a meeting with constituents, killing at least five people and wounding several others in a rampage that rattled the nation.

Giffords was among at least 10 people wounded, and the hospital said her outlook was "optimistic" and that she was responding to commands from doctors despite having a bullet go through her head. The hospital said a 9-year-old child was among the dead, and a U.S. Marshal said a federal judge was also fatally shot in the attack.

Giffords spokesman C.J. Karamargin said an unspecified number of her staff members were injured in the shooting. Congressional officials said an aide to the Democrat was killed, and President Barack Obama said five people died in all. The reaction to the shooting was swift and rippled across the globe. Obama held a nationally televised news conference to express his condolences. The shooting cast a pall over Capitol as politicians of all stripes denounced the shooting as a horrific act of violence. Capitol police asked members of Congress to step up security in the wake of the shooting, and some politicians expressed hope that the killing spree serves as a wakeup call at a time when the political climate has become so emotionally charged.

"I am horrified by the senseless attack on Congresswoman Gabrielle Giffords and members of her staff," newly elected House Speaker John Boehner said. "An attack on one who serves is an attack on all who serve. Acts and threats of violence against public officials have no place in our society. Our prayers are with Congresswoman Giffords, her staff, all who were injured, and their families. This is a sad day for our country."

Police say the shooter was in custody, and was identified by people familiar with the investigation as Jared Loughner, 22. Pima County Sheriff's officials said he used a pistol to carry out the shooting spree. U.S. officials who provided his name to the AP spoke on condition of anonymity because they were not authorized to release it publicly.

His exact motivation was not immediately clear. Federal law enforcement officials were poring over captured versions of a MySpace page that belonged to Jared Loughner and over Youtube video published to the Internet weeks ago under an account "Classitup10" and linked to him. The MySpace page, which was removed within minutes of the gunman being identified by U.S. officials, 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, which featured text against a dark background, Loughner described inventing a new U.S. currency and complained about the illiteracy rate among people living in Giffords' congressional district in Arizona. Two spellings of his last name were given in the aftermath of the shooting -- Loughner and Laughner.

"I know who's listening: Government Officials, and the People," Loughner wrote. "Nearly all the people, who don't know this accurate information of a new currency, aren't aware of mind control and brainwash methods. If I have my civil rights, then this message wouldn't have happen (sic)."

U.S. Marshal for Arizona David Gonzales confirmed to the Associated Press that U.S. District Judge John Roll was one of the dead.

Giffords, 40, was first elected to Congress amid a wave of Democratic victories in the 2006 election, and she won a narrow victory against a tea party favorite in the 2010 election. She has been mentioned as a possible Senate candidate in 2012 and gubernatorial prospect in 2014.

Giffords is married to astronaut Mark E. Kelly, who has piloted space shuttles Endeavour and Discovery. The two met in China in 2003 while they were serving on a committee there, and were married in January 2007.

Sen. Bill Nelson, chairman of the Senate Commerce Space and Science Subcommittee, said her husband is training to be the next commander of the space shuttle mission slated for April. His brother is currently serving aboard the International Space Station, Nelson said.

Giffords, known as "Gabby" in Arizona, tweeted shortly before the shooting, describing her "Congress on Your Corner" event: "My 1st Congress on Your Corner starts now. Please stop by to let me know what is on your mind or tweet me later."

"It's not surprising that today Gabby was doing what she always does, listening to the hopes and concerns of her neighbors," Obama said. "That is the essence of what our democracy is about."

Giffords has drawn the ire of the right in the last year, especially from politicians like Sarah Palin over her support of the health care bill.

Her Tucson office was vandalized a few hours after the House voted to approve the health care law in March, with someone either kicking or shooting out a glass door and window. In an interview after the vandalism, Giffords referred to the animosity against her by conservatives. Palin listed Giffords' seat as one of the top "targets" in the midterm elections because of the lawmakers' support for the health care law.

"For example, we're on Sarah Palin's targeted list, but the thing is, that the way that she has it depicted has the crosshairs of a gun sight over our district. When people do that, they have to realize that there are consequences to that action," Giffords said in an interview with MSNBC.

In the hours after the shooting, Palin issued a statement in which she expressed her "sincere condolences" to the family of Giffords and the other victims.

Law enforcement officials and reporters from around the country descended on Tucson, the second biggest city in the state and home to the University of Arizona. The scene has been converted into a command post with about a dozen or so emergency vehicles and agents in FBI jackets milling about the location.