Gunmen shot and killed an American man Tuesday as he left his car in the capital of the West African nation of Mauritania, police and witnesses said.

Two men had initially tried to kidnap the man, but he resisted and they shot him when they realized they could not overpower him, a police officer said. The office did not give his name because he was not authorized to speak to the press.

Witness Bilal Ould Mohamed and other neighbors said the man was a U.S. professor teaching at a center specializing in computer science in El Kasr, a lower-class neighborhood in Nouakchott.

Mohamed, a butcher, said he saw at least two young men rush up to the middle-aged man and shoot him several times in the head and face. Mohamed said he tried to stop them, but they pointed their gun at him before running off.

An AP correspondent at the scene saw officials from the U.S. Embassy arrive as the body lay on the pavement. The embassy in Nouakchott could not immediately be reached for comment.

Extremist violence in Mauritania, a moderate Muslim nation, has increased. In 2007, a group of French picnickers was killed. The gunmen were believed to be linked to Al Qaeda's north Africa branch and the incident prompted organizers of the famous Dakar Rally to cancel the trans-Sahara car race.