CAIRO – A popular American teacher who described himself on Twitter as "Libya's best friend" was gunned down in Benghazi on Thursday while jogging, raising fears that foreigners are among those being targeted in the surge of assassinations in that restive city.

Ronnie Smith, 33, who described himself online as a Texas native, was a chemistry teacher at Benghazi's International School and had lived in the city for 18 months. He died not far from the U.S. Special Mission site and CIA compound, where attackers killed the U.S. ambassador to Libya, Christopher Stevens, and three other Americans on Sept. 11, 2012.

Since then, foreigners have been scarce in Benghazi, Libya's second-largest city, as militias that helped bring down the late leader Moammar Gadhafi have battled government forces for control. Militias dominate the city, and they have said that Westerners, whom they accuse of threatening their Islamist vision for Libya, are among their top targets. In addition to the United States, Great Britain and Italy have closed their diplomatic missions in Benghazi.

But it isn't clear that the militias have the backing of residents. Smith seemed to be particularly popular not only with students but also with liberal groups, who said they knew him.

On Twitter, his students created two hashtags, #ThankYouSmith and #MrSmithMemories, to remember their teacher.

"ThankYouSmith for everything, for risking your life everyday by being here. your presence in school will be missed," wrote one student, @yzentani.

"You taught me to think like the electron and be the electron," said Rahman Bader.

"There is no better man," posted @criminimed.

The U.S. government confirmed that an American had been killed but didn't release Smith's name. "We offer our condolences to the victim's loved ones," State Department spokeswoman Marie Harf said.

No organization claimed responsibility for the shooting.

Since Stevens' death last year, militias and insurgent groups, led by the extremist group Ansar al Shariah, have increased their hold on Benghazi, assassinating police officers, government officials and those thought to support Libya's government.

An Ansar al Shariah spokesman, Mohammed al Baraasy, told Libyan television last month that civilians weren't being targeted in the assassination campaign. But in October, Islamists called for the kidnapping of American citizens after U.S. special operations forces snatched a suspected Al-Qaida member, Abu Anas al Libi, in front of his house in Tripoli. He was later taken to New York to stand trial on charges stemming from the 1998 bombings of U.S. embassies in Kenya and Tanzania.

Smith apparently was aware of the risk he might face, but he seemed to take the threat lightly in a tweet he posted Nov. 5: "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?"

The Austin, Texas, church that he attended with his wife, Anita, and their toddler son said Smith had been teaching in Benghazi for the last year and a half and that Smith had planned to be home for Christmas.

"Anita and their son had returned to the U.S. and are safe with family. Ronnie, out of a sense of dedication, had stayed in Libya to be with his students through their midterm exams," said Daphne Bamburg, the executive pastor of operations at the Austin Stone community church. "Ronnie's greatest desire was for peace and prosperity in Libya."

The Associated Press contributed to this report.