Canadians are being urged to immediately leave areas of Libya, including the eastern city of Benghazi, in response to a heightened risk of terrorism targeting expatriates and foreign travellers.

The federal government issued a travel advisory Thursday evening warning its citizens to avoid all non-essential travel to Benghazi, Bani Walid and regions of Sabha and Kufra citing what it called an "unpredictable security situation."

Britain, Germany and the Netherlands also urged their citizens earlier Thursday to leave Benghazi due to what was described as an imminent threat against Westerners.

The warnings come a day after U.S. Secretary of State Hillary Rodham Clinton testified to Congress about the deadly September attack on the U.S. consulate in Benghazi that killed four Americans, including the ambassador to Libya.

Canada's Foreign Affairs department warned on its website that that "terrorist attacks could occur at any time and could target areas frequented by expatriates and foreign travellers" and described ongoing clashes, including indiscriminate shelling, between pro-government militia and Gadhafi loyalists in Bani Walid. It also warned of reported clashes between various armed groups in Sabha and Kufra.

The foreign ministries of Britain, Germany and the Netherlands issued statements variously describing the threat as specific and imminent but none gave details as to its exact nature.

Germany and Britain urged their nationals still in Benghazi to leave "immediately" while Dutch Foreign Ministry spokesman Thijs van Son said that "staying in this area is not to be advised."

It was not immediately clear how many people could be affected.

Many foreigners have left in recent weeks

Britain's Foreign Office said likely "dozens" of its citizens were in the city, while Dutch Foreign Ministry spokesman Thijs van Son said there are four Dutch citizens registered as being in Benghazi and possibly two more.

Several countries have for months advised against all travel to the city, especially after the U.S. consulate was attacked, and local residents said that many foreigners had already left in recent weeks.

Benghazi, a city of 1 million people, is a business hub where many major firms employ Westerners. It also was where the Libyan uprising against longtime dictator Moammar Gadhafi began in 2011. Gadhafi was eventually toppled and killed after NATO backed the rebel movement, and the Arab country has since struggled with security. Al-Qaeda-linked militants operate in the country alongside other Islamist groups.

Adel Mansouri, principal of the International School of Benghazi, said British and foreign nationals were warned two days ago about a possible threat to Westerners.

He said the school's teachers were given the option of leaving but decided to stay. The school has some 540 students. Most are Libyan with some 40 per cent who hold dual nationality. Less than five per cent are British while 10 to 15 students have U.S.-Libyan nationality, Mansouri said. Classes were not due to resume until Sunday because of a holiday Thursday.

"We told the British ambassador we are staying, and we'll be in touch," said Mansouri, himself a Libyan-British dual national. "We don't see a threat on the ground."

Saleh Gawdat, a Benghazi lawmaker, said French doctors who were working in Benghazi hospitals have left the city and that the French cultural centre has closed out of concerns about potential retaliation over the French-led military intervention in nearby Mali, which began two weeks ago.

Foreigners, Libyan officials targeted in recent months

Violence in Benghazi has targeted both foreigners as well as Libyan officials in recent months — with assassinations, bombings and other attacks.

In addition to the Sept. 11 attack on the U.S. consulate, an Italian diplomat's car was fired on by militants in Benghazi. The consul, Guido De Sanctis, wasn't injured in the attack earlier this month, but the incident prompted Italy to order the temporary suspension of its consular activities in the city and send its foreign staff home.

Islamist extremists are often blamed for targeting security officials who worked under Gadhafi, as a kind of revenge for torturing or imprisoning them in the past. Many city residents also blame Gadhafi loyalists who they say are trying to undermine Libya's new leaders by sowing violence.

Noman Benotman, a former Libyan jihadist with links to al-Qaeda who is now an analyst at London's Quilliam Foundation, said other groups inspired by the extremist network have been gaining a following since Gadhafi's fall. There have been nearly a dozen attacks against Western targets in Libya recently, he said.

"It's the same al-Qaeda ideology that is driving these militants," Benotman said.

He added, however, that the militants were unlikely to target oil or gas installations in Libya because they need support from the population. "Targeting these installations would turn Libyan workers and tribes against them," he said.

Oil companies working in other parts of Libya said they were aware of government warnings to citizens but there were no immediate plans for evacuations.