(Update with release, background)
SANAA, March 25 (Reuters) - Yemeni security forces freed two Westerners unharmed on Tuesday shortly after they were kidnapped by gunmen in the capital Sanaa, police sources said, in an incident highlighting the growing security threat in the country.
Kidnapping is common in U.S.-allied Yemen, where the government is struggling to contain an insurgency from Islamists linked to al Qaeda, a southern separatist movement, fighting in the country's north and sporadic conflicts with armed tribes.
Police said the security forces tracked the two kidnappers to a house where they were holding the pair, one of whom was Italian, and managed to free them safely after surrounding the premises.
They said one of the Westerners was a diplomat for the United Nations and the other was a woman accompanying him.
Local residents said they heard gunshots in the area, but an initial exchange of fire was followed by negotiations, the police sources said, before the hostages were released.
They had been seized earlier on Tuesday when the kidnappers stopped their car in the Hada district of Sanaa, where many diplomatic missions are located, police sources said.
Hostage-taking is sometimes carried out by militants aiming to intimidate Westerners, but is also used as a tactic by tribesmen to resolve disputes with the government, and by opportunists hoping to sell hostages on to other groups.
Three foreigners - a Czech doctor, a British oil worker and a German - were seized in February.
The impoverished Arabian Peninsula country, which borders oil giant Saudi Arabia, has long wrestled with instability, internal conflicts and poor governance.
The United States, along with some other Western and Gulf countries, is working with an interim government to effect a political transition after former president Ali Abdullah Saleh was forced from office in 2012 by street protests.
(Reporting By Mohammed Ghobari; Writing by Angus McDowall; Editing by Mark Heinrich)