Azerbaijan says it has foiled an Islamist plot to carry out a terrorist attack on state agencies and diplomatic missions in the capital, Baku.
Security forces raided a group planning the attacks, killing one member and arresting several others, a national security ministry statement said.
The UK embassy closed on Monday citing security concerns, while the US embassy suspended its consular services.
The ministry said a renegade army officer was involved in the plot.
The lieutenant deserted his unit this month, taking with him four assault rifles, a machine gun and 20 hand grenades, the statement said.
Ministry spokesman Arif Babayev told Reuters news agency the officer was one of those held.
Security forces tracked the group to Mastaga, a village 30km (20 miles) north-east of Baku, on Saturday, where one of its members offered resistance and was killed.
"That prevented a large-scale, horrifying terror attack that was being prepared by members of this group against several state structures in Baku and embassies and missions of the countries which are members of the international anti-terror coalition," the statement said.
A hunt was going on for other members of the group, it said.
The US embassy told US citizens it had closed its consular office until further notice and urged them to "maintain a high level of vigilance".
Both US and UK embassies have refused to comment on the nature of the threat against them.
Correspondents say the Azerbaijani authorities have arrested dozens of people suspected of militant activity but the country has no history of Islamist violence against Westerners.