Stephen Harper spent about 15 minutes hidden in a Parliament Hill closet after a gunman stormed Centre Block where he and the rest of the Conservative caucus were guarded by MPs who'd fashioned sharp spears from flagpoles, sources say.

After they heard gunfire outside their meeting room door Wednesday, members of Parliament snapped close to 15 flagpoles to make weapons.

Some positioned themselves on risers that flanked doors, ready to attack an assailant.

Story continues below advertisement

Further reading: What we know so far on the attack on Ottawa

"There were 15 flags up at caucus and all but two were taken down," one MP recalled.

"These guys were up there holding these spears ready to impale anyone who came in," the source said.

"It was that or get mowed down," the member of Parliament said of the threat posed by a gunman who was ultimately shot dead by Parliament Hill security.

Mr. Harper, meanwhile, had been whisked into a closet in the Centre Block room shortly after the gunfights outside began.

There were more than 150 Tory MPs stuck in this caucus room during the ordeal.

Many MPs thought the Prime Minister had managed to get out of the room and didn't know he was sequestered in what amounted to a cubbyhole.

Story continues below advertisement

"Someone knew there was a closet there so they stuck him in there," the source said.

"So for a lot of people it was as though he was gone."

The Prime Minister's RCMP security detail ultimately rescued him and whisked him out of the building.

It was a surprise to many Conservatives when Mr. Harper emerged from his hiding place to exit Parliament Hill.

Some MPs kept their flagpole weapons as souvenirs.

"Everyone was taking their spears home," the MP said. "I'm going to frame mine."

Story continues below advertisement

One soldier was killed by the gunman Wednesday and a Hill security guard was shot fighting the assailant but is expected to make a full recovery.

Tory MPs reunited with Mr. Harper Wednesday evening at the Foreign Affairs building and Democratic Reform Minister Pierre Poilievre brought his spear as a memento, another source said.