CBC reporters Sasa Petricic and Derek Stoffel have been released from detention in Istanbul, Turkey.

The two journalists had been picked up by police earlier on Wednesday while covering ongoing anti-government protests in Istanbul's Taksim Square. The pair had been held all day.

"We're out!" Petricic tweeted.

"Arrested taking pics of city crew removing protester barricade," he tweeted. "Accused [of] impeding road works & resisting arrest."

He also wrote that he spent several hours in a cell with "eight young guys arrested for very frivolous things," included two who were detained while bringing food to protesters.

Stoffel tweeted following his release: "My exclusive 'tour' of the Turkish justice system is over! Thanks for all the kind comments! And very big thanks to all at @CBCNews...the Cdn Foreign Affairs dept. and my new Turkish friends for helping expedite my release! It's late so going to sleep. Night all!"

The release of the two correspondents was due, in part, to some behind-the-scenes work by Foreign Affairs Minister John Baird and the Turkish Ambassador to Canada, Tuncy Babali.

"Pleased to hear @CBCNews journalists have been released in #Istanbul," Baird tweeted. "Thanks to the Cdn Consul General and the Gov't of Turkey, including Amb. Babali, for their co-operation in this matter."

Earlier, CBC News editor-in-chief Jennifer McGuire said the two correspondents had met with Canadian consular officials in Istanbul, and they spoke to their lawyer in advance of giving statements to police.

The House of Commons unanimously endorsed a motion put forward by MP Bob Rae condemning the arrest of the two Canadian journalists and calling for their release.

Babali had told the CBC he doesn't know why Petricic and Stoffel were detained. The ambassador said he learned of their detention after he was contacted by Baird, who expressed his concern.

At around 6 p.m. local time Wednesday, Petricic had tweeted one word: "Arrested."

Stoffel's last tweeted message before his detention included a photo of heavy machinery clearing out barricades erected by protesters near Istanbul's Taksim Square.

The two journalists subsequently sent messages while in police custody that they were OK.

Focal point of protests

Taksim Square has become a focal point for recent anti-government protests, which are shaping up as one of the biggest challenges to the 10-year rule of Turkish Prime Minister Recep Tayyip Erdogan.

Demonstrators say Erdogan is becoming more autocratic and trying to impose religious views on the country, charges that he and his allies deny.

As of Monday night, three people had died and about 5,000 people had been treated for exposure to tear gas or other injuries relating to the demonstrations, according to the Turkish Medical Association.

Reporters Without Borders released a statement on Wednesday saying it was "becoming increasingly concerned about the dangerous climate for journalists covering Turkey’s protest movement."

In January, the rights group described Turkey as "the world’s biggest prison for journalists" and ranked the country 154th in its 2013 Press Freedom Index.