Smith taught chemistry at the International School in the eastern Libya city and was jogging near US consulate, says official

Gunmen shot and killed a young American teacher as he was jogging in the eastern Libyan city of Benghazi on Thursday, amid an upsurge of violence between radicals and security forces.

Ronnie Smith, a chemistry teacher at the city’s international school, was killed while on his regular afternoon running route in Dubai Street, an upmarket area of the city.

His death comes with Libya enduring some of the worst violence since the 2011 revolution, with nearly three weeks of clashes between militias and the army in both Benghazi and Tripoli, the capital. Three Libyan army soldiers were killed in the eastern port city earlier on Thursday.

Last week the army stormed four bases of Ansar al-Sharia, the Islamist militia blamed by some for the killing last year of American ambassador Chris Stevens at the US consulate. Bombings and assassinations have continued on a near-daily basis.

The principal of the international school, Peter Hodge, who has kept the school open despite the violence, told local media Smith was “much loved.”

Smith had worked in the city for 18 months. On the profile of his Twitter account, he described himself as “Libya’s best friend”. But his tweets were also critical of Islamist militias. In October he tweeted: “Libya Islamists are threatening kidnappings. As if they can fit kidnapping into a 2hr (sic) work day that already includes a nap. Losers.”

Then on 5 November he tweeted: “I understand I teach at a school of rich kids, so if (and when) I’m kidnapped by Ansar Al-Sharia, who’s gonna pay the ransom?”

Diplomats in Tripoli have previously cautioned against making derogatory or insulting remarks on social media, which is widely read in Libya.

Smith graduated from the University of Texas , Austin, with a masters degree in chemistry in 2006. The university said in a statement that its community was "shocked and saddened" by Smith's death. It added: "He was an enthusiastic and outgoing student. His death is a tragedy for the campus and our nation."

A wave of attacks against western targets has left Benghazi almost empty of foreigners. Both the American and British embassies have advised against all travel to Benghazi for their citizens. The US embassy website posted a warning on 16 November telling its citizens to exercise “extreme caution” after the upsurge of violence.

In October the Maltese consul fled the city after death threats and last month a bomb exploded outside the joint Finnish and Swedish consulate. Britain’s consulate was closed after a rocket attack on the ambassador in June last year.

The latest upsurge of violence began with the killing of 47 protestors, and wounding of 538 by a militia in Gharghour, Tripoli, on 15 November. The massacre prompted anti-militia protests and violence across the country.

The Libyan prime minister, Ali Zaidan, declared this week that Benghazi militias must disarm by the middle of the month, but it remains unclear if Libya’s security forces are strong enough to enforce the order. The army this week announced it lacked the troops to maintain security in Benghazi. Four protestors were shot and wounded in anti-militia protests in the eastern city of Derna on Monday.

Many Benghazi residents feel afraid. “We don’t want to go out, it is not safe, bombings and killings all the time,” said Mohammed, a local businessman, who declined to give his full name fearing reprisals.

Central government control remains weak outside the capital, Tripoli. Much of the country is a patchwork of militia fiefdoms. Striking militias and army units continue to blockade the bulk of Libya’s exports, with the government declaring this week that it is running out of currency reserves.

Libyans are traumatised by the violence. “The trend of targeting foreigners can easily spread to other cities if things aren't dealt with immediately,” said Mohamed Eljarh, a prominent Libyan journalist. “There is an absolute and urgent need for reinforcement of security in Benghazi. Libya cannot deal with the security situation on its own.”

Additional reporting by Tom Dart in Houston, Texas