A gunman shot and killed a soldier at a war memorial in Ottawa, before police engaged in a gun battle inside the parliament building.
Police confirmed a gunman was shot dead, but Canada's capital remained on alert through much of the day.
PM Stephen Harper said the country "would not be intimidated" by violence.
The shooting came hours after Canada raised its terror threat level. On Monday another soldier was killed in a hit-and-run attack by a Muslim convert.
The country earlier this month announced plans to join the US-led campaign of air strikes against Islamic State (IS) militants in Iraq.
There is no confirmation any of this week's attacks are linked to IS or the new military campaign.
But Mr Harper, speaking late on Wednesday, said the attack would strengthen Canada's resolve in the fight against extremism alongside its allies.
"They will have no safe haven," he said.
Mr Harper was addressing MPs at the time of the shooting but was safely evacuated.
Citing unnamed Canadian officials, US and Canadian news agencies identified the dead gunman as Michael Zehaf-Bibeau.