The Prime Minister’s Office has apologized for posting two videos online that showed the faces of Canadian special forces soldiers.

The videos were filmed during Prime Minister Stephen Harper’s recent trip to Iraq and Kuwait. Members of the media travelling with Harper were asked to sign agreements not to publish any images of the elite JTF-2 troops who were providing security.

However, some of those soldiers were shown in videos posted on Harper’s official “24/Seven” website.

After concerns were raised about the troops who appeared in the videos, the PMO pulled them from the website. Still, a senior government official told The Canadian Press Tuesday that the videos didn’t violate security protocols and would be reposted after going through another review.

A few hours later, however, the PMO admitted that the videos should never have been posted and apologized.

"When concerns were raised about a few specific images, these were taken down immediately so we could review that the protocols were applied properly,” the PMO said in a statement.

"After a second review, it became apparent that two of the videos should not have been posted.

"We regret the error and are reviewing protocols for such images."

A government official also said earlier that the Department of National Defence had approved the videos before they appeared online, but sources have told CTV News that did not happen.

NDP’s national defence critic, Jack Harris, slammed the Conservatives for the error during question period Tuesday, asking why the PMO broke security rules and who would take responsibility for the “fiasco.”

James Bezan, the parliamentary secretary for the minister of national defence, responded by repeating the PMO’s statement. He also said the videos will not be reposted.

“We regret this error,” he said.

In a statement issued Tuesday afternoon, General Tom Lawson, chief of the defence staff, said an assessment by the Canadian Forces determined that two videos should not be posted, “though the risk is assessed as low.”

He also said that “there is certainly no requirement for any CAF personnel to be withdrawn from Op IMPACT.”

Security expert David Hyde said the PMO’s mistake was baffling.

“This is an egregious security breach, one of the worst I can recall in recent times,” he told CTV’s Power Play.

Hyde said the PMO staffers who worked on the video could have easily blurred the soldiers’ faces before posting the images.

The JTF-2 troops carry out some of the most sensitive Canadian military operations. Hyde said revealing their identities is especially dangerous now, amid increasing threats from Islamic State militants and other extremist groups.

NDP deputy leader Megan Leslie said there’s “no excuse” for compromising the soldiers for the sake of another “promotional video.”

“Not only has the security of these soldiers been breached, it was for a promo video,” she told Power Play.

“It’s starting to look more and more like the prime minister’s entire trip is more about his election brochure and his election videos than it is about the soldiers.”

Harper’s 24/Seven feed, launched in January 2014, has long been criticized by opposition parties as being too partisan and self-serving, and all at the expense of taxpayers.

The PMO has said that three people, on average, are involved in the weekly publishing of 24/Seven videos as part of their “regular web publishing duties.”