An American, a Canadian and a Yemeni employed at a Western oil firm in Yemen have been shot dead, according to an official in the capital Sanaa.
The attacker wounded another Westerner before turning his gun on himself, the official said.
He told Reuters news agency that the attack occurred in the oil-rich province of Marib, about 170 kilometres (105 miles) east of Sanaa.
Opposition to the US has been widespread in Arab countries over the coming American-led war on Iraq.
The Yemeni official said the gunman was a carpenter working on the premises of the oil firm.
It is believed to be the US company Hunt Oil, the only western oil firm in Marib.
The nationality of the wounded foreigner is not known.
Yemen - where many people carry guns - has been a focus for anti-Western attacks in recent years.
In December a gunman believed to have links with Osama bin Laden's al-Qaeda network killed three US missionaries at a hospital in the south of the country.
Suspected militants attacked a French tanker off Yemen in October - about a year after 17 sailors died in a suicide attack on the US destroyer Cole in the port of Aden.
Last week Canada warned its citizens not to travel to Yemen.
"The heightened tensions as a result of the Iraq situation, together with increased threats globally from terrorism, put Canadians at greater risk," it said.
Since the 11 September attacks the Yemeni authorities have been cracking down on Islamic militants.