Leading political figures have offered messages of condolence and support following an attack on Canada's parliament building.

A soldier was shot dead by an armed gunman at Ottawa's War Memorial. Nearly 30 gun shots were heard from inside the Canadian parliament building, where the gunman was eventually chased down and shot.

The world has reacted with shock to what is being termed as 'the end of Canada's innocence.'

White House press secretary Josh Earnest confirmed that US President Barack Obama has offered support to Canada, reported CBC News.

"The thoughts and prayers of everybody here at the White House go out to the families of those who were affected by today's shooting in Canada as well as to the family of the soldier who was killed earlier this week. Canada is one of the closest friends and allies of the United States and from issues ranging from the strength of our NATO alliance to the Ebola response to dealing with ISIL [Isis], there is a strong partnership and friendship and alliance between the United States and Canada," said Earnest.

United Nations Secretary General Ban Ki-moon also confirmed his support to Canadians.

"The secretary general is aware of the situation unfolding in Ottawa, including in the Canadian Parliament, during which a soldier has reportedly been shot. He hopes the situation will be brought quickly under control by Canadian law enforcement authorities. His thoughts are with the people and government of Canada at this difficult time," read a statement provided to CBC News.

Writing on Twitter, British Prime Minister David Cameron said he was "appalled by today's attack in Ottawa."