Two deadly attacks in three days against members of the military stunned Canadians and raised fears their country was being targeted for reprisals for joining the U.S.-led air campaign against an extremist Islamic group in Iraq and Syria.

"We will not be intimidated. Canada will never be intimidated," Prime Minister Stephen Harper vowed in a nationally televised address hours after a masked gunman killed a soldier standing guard at Ottawa's war memorial shortly before 10 a.m. on Wednesday. The suspect then stormed Parliament in a dramatic attack that was stopped cold when he was shot to death by the ceremonial sergeant-at-arms.

Harper called it the country's second terrorist attack in three days. A man Harper described as an "ISIL-inspired terrorist" on Monday ran over two soldiers in a parking lot in Quebec, killing one and injuring another before being shot to death by police. Like the suspect from Wednesday's shooting in Ottawa, he was a recent convert to Islam.

Investigators offered little information about the gunman in Ottawa, identified as 32-year-old petty criminal Michael Zehaf-Bibeau. But Harper said: "In the days to come we will learn about the terrorist and any accomplices he may have had."

Witnesses said the soldier posted at the National War Memorial, identified as Cpl. Nathan Cirillo, was gunned down at point-blank range by a man carrying a rifle and dressed all in black, his face half-covered with a scarf. The gunman appeared to raise his arms in triumph, then entered Parliament, a few hundred yards away, where dozens of shots soon rang out, according to witnesses.

People fled the complex by scrambling down scaffolding erected for renovations, while others took cover inside as police with rifles and body armor took up positions outside and cordoned off the normally bustling streets around Parliament.

On Twitter, Canada's justice minister and other government officials credited 58-year-old sergeant-at-arms Kevin Vickers with shooting the attacker just outside the MPs' caucus rooms. Vickers serves a largely ceremonial role at the House of Commons, carrying a scepter and wearing rich green robes, white gloves and a tall imperial hat.

At least three people were treated for minor injuries.

In Washington, President Barack Obama condemned the shootings as "outrageous" and said: "We have to remain vigilant." The U.S. Embassy in Ottawa was locked down as a precaution, and security was tightened at the Tomb of the Unknown Soldier at Arlington National Cemetery just outside Washington.

Harper vowed that the attacks will "lead us to strengthen our resolve and redouble our efforts" to keep the country safe and work with Canada's allies to fight terrorists.

Court records that appear to be the gunman's show that he had a long rap sheet, with a string of convictions for assault, robbery, drug and weapons offenses, and other crimes.

Tony Zobl said he witnessed the Canadian soldier being gunned down from his fourth-floor window directly above the National War Memorial, a 70-foot, arched granite cenotaph, or tomb, with bronze sculptures commemorating World War I.

"I looked out the window and saw a shooter, a man dressed all in black with a kerchief over his nose and mouth and something over his head as well, holding a rifle and shooting an honor guard in front of the cenotaph point-blank, twice," Zobl told the Canadian Press news agency. "The honor guard dropped to the ground, and the shooter kind of raised his arms in triumph holding the rifle."

The Canadian Broadcasting Corp. had video of the gunman going to his car alone with his weapon after the shooting at the memorial. The car was later spotted parked in front of Parliament Hill, just down the block.

Cabinet minister Tony Clement tweeted that at least 30 shots were heard inside Parliament, where Conservative and Liberal MPs were holding their weekly caucus meetings.

"I was just taking off my jacket to go into caucus. I hear this pop, pop, pop. Possibly 10 shots, don't really know. Thought it was dynamite or construction rather than anything else," said John McKay, a member of Parliament.

He said security guards then came rushing down the halls, herding them toward the back of the buildings.

"And then we started talking to another woman and she was apparently inside the library of Parliament, saw the fellow, wearing a hoodie, carrying a gun," McKay said, "and then the implications of this start to sink in."

The attack came two days after a recent convert to Islam killed the Canadian soldier and injured another with his car in a parking lot in the Quebec city of Saint-Jean-Sur-Richelieu. The killer had been on the radar of federal investigators, who feared he had jihadist ambitions and seized his passport when he tried to travel to Turkey.

Canada had raised its domestic terror threat level from low to medium Tuesday because of what it called "an increase in general chatter from radical Islamist organizations." As recently as Tuesday, Canada sent eight fighter jets to the Mideast to join the battle against Islamic State.