A GUNMAN opened fire at a hall of residence and a classroom at a US university today, killing 31 people in the deadliest campus shooting in the country's history.

The gunman was killed but it was unclear if he was shot by police or took his own life after the shooting spree at Virginia Tech.

Dozens of other people were injured, several jumping from windows to escape the gunman.

President Bush was described as shocked and saddened by the mass shooting.

''He was horrified and his immediate reaction was one of deep concern for the families of the victims, the victims themselves, the students, the professors and all the people of Virginia who have dealt with this shocking incident,'' White House deputy press secretary Dana Perino said.

She said the president ''believes that there is a right for people to bear arms, but that all laws must be followed'', noting that Mr Bush and education secretary Margaret Spellings held a conference on school gun violence last October.

''Certainly, bringing a gun into a school dormitory and shooting ... is against the law and something someone should be held accountable for,'' Ms Perino said.

She said that federal assistance is available if Virginia authorities request help, adding it was premature to discuss whether Mr Bush would travel to the Blacksburg area.