(Adds suicide bomber, other details)
DUBAI, July 4 (Reuters) - At least six people, including a suicide bomber and two security personnel, were killed at a Saudi-Yemeni border crossing on Friday, in attacks that highlighted the threat posed by militants to the security of both nations.
Saudi Arabia, the world's biggest oil exporter, has long viewed its 1,800 km (1,100 mile) border with impoverished, conflict-ridden Yemen as a major security challenge and has been building a fence to deter militants and criminals.
On Friday, gunmen killed the commander of a border patrol on the Saudi side of the Wadia border post and security forces then killed three of the attackers in an ensuing firefight, the Saudi state news agency SPA said.
Separately, Yemen's state agency Saba reported that a suicide bomber had driven a car laden with explosives into the Yemeni side of the Wadia border crossing, killing himself and one soldier and wounding another.
After the attack, Yemeni security forces chased militants who fled from the scene in two cars into the desert, Saba said, citing a military source.
Earlier, in comments suggesting it was the same group of militants involved in the attacks on both sides of the border, a Yemeni official told Reuters the gunmen had escaped into Saudi Arabia after attacking the Yemeni border post.
The official said the attackers were al Qaeda militants.
The SPA agency did not say who was thought to be behind the attack on the Saudi side of the border post. It said security forces had arrested one of the gunmen and were searching for one or two others believed to be hiding in the area.
The Wadia crossing is in the southeastern Yemeni province of Hadramout, which stretches from the port of Mukalla in the south to the Saudi border, through arid valleys and empty desert, landscape that al Qaeda militants use to their advantage across the Middle East.
Saudi Arabia has been building the security fence along its border with Yemen since 2003, though work has often been interrupted by protesting tribesmen who say it prevents them accessing pastures for their livestock.
The kingdom, a key regional ally of the United States, overcame its own al Qaeda insurgency almost a decade ago but it has watched with alarm the recent military advances by radical Sunni Islamists in neighbouring Iraq.
In May, Riyadh said it had detained 62 suspected al Qaeda militants with links to radicals in Syria and Yemen who were plotting attacks on government and foreign targets in the kingdom. (Reporting by Rania El Gamal in Dubai and Mohammed Mukhashaf in Aden; Editing by Gareth Jones)