The Canadian Embassy in Tripoli has suspended operations and staff members have been withdrawn from Libya, the Canadian government said today, citing the "unpredictable security environment."

The closing follows similar actions by other countries as fighting in Libya grows more intense. In the last three weeks, Libya has descended into its deadliest violence since the 2011 war that ousted ruler Moammar Gadhafi after 42 years in power.

On Saturday, the United States also moved its diplomats from Tripoli to neighbouring Tunisia and shut its embassy.

Foreign Affairs Minister John Baird and Lynne Yelich, minister of state for foreign affairs, said in a statement that Canadian diplomats will do the same, operating from Canada's Embassy in Tunis, Tunisia, where consular and passport services will be available to Canadians remaining in Libya.

“The Government of Canada takes the safety and security of our diplomats abroad very seriously," Baird's statement said.

Violence flares in Tripoli, Libya

Fighters from the Islamist Misarata brigade fire towards Tripoli airport in Libya on July 26. On Monday, Canada announced it was removing its diplomats from the country. (Associated Press)

It also indicated an intention to return to Libya once "appropriate measures are put in place to respond to the changing operational environment."

The statement added: "Canada remains committed to supporting Libya's democratic transition, and we urge all parties to stop the violence and resolve their differences by peaceful and democratic means."

A spokesman for Baird told CBC News the Canadian government will reopen the embassy as soon as it is safe to do so.

"As soon as security conditions permit, Canada will reopen its embassy to work with our Libyan partners to build a democratic and secure state," Rick Roth said in an email to CBC News.

Canada will continue to support Libya's transition to democracy just as it did during the revolution in 2011, Roth said adding, "The lack of progress in that direction is deeply disappointing.

"We have been firm in our calls for Libya’s leaders to foster a meaningful national dialogue, which provides for the active democratic participation of all its citizens."

With files from The Canadian Press