By Andrew Hammond

SANAA (Reuters) - Yemen's president offered dialogue to Islamist militants including al Qaeda on Wednesday, but said they must agree first to put down weapons and reject support from abroad.

Restoring stability to Yemen has become an international priority given fears that jihadi fighters could entrench themselves in a country and threaten world No. 1 oil exporter Saudi Arabia next door and important world shipping lanes.

Al Qaeda in the Arabian Peninsula (AQAP) and other Sunni Muslim militant groups including Ansar al-Sharia gained ground last year during a popular uprising that forced out veteran autocratic president Ali Abdullah Saleh, who had been seen by Washington as its best ally in containing militants.

Since replacing Saleh in February, President Abd-Rabbu Mansour Hadi has waged an army offensive to oust such groups from areas of Abyan province in south Yemen while the United States has stepped up a campaign of missile strikes on them.

"I always say that, despite the blood that has been spilled, homes destroyed and people displaced, it is possible to open a dialogue," Hadi said in a speech broadcast on the occasion of the 50th anniversary of the Yemeni republic.

"But (this is) on condition that al Qaeda announces its agreement to cast aside its weapons, repent of its extremist ideas that are far from Islam, and give up protecting armed elements from outside the country."

AL QAEDA UNLIKELY TO RESPOND

It is unlikely that the hardcore ideologues who lead al Qaeda would take up Hadi's offer. But it may have more resonance with Yemenis who have been sucked into the militant orbit for social or economic reasons.

They include members of Ansar al-Sharia, a local Yemeni phenomenon that some analysts say may have been set up with hidden state backing in the final year of the Saleh era as a way of confusing the political landscape and dividing his opponents.

AQAP, which has carried out attacks in Yemen, wounded Saudi Arabia's deputy interior minister in a bomb blast, and tried to put bomb packages on U.S.-bound airliners, is an amalgamation of Saudi and Yemeni al Qaeda figures under a largely Saudi command.

Yemen's new government and Washington have made tackling militants their top priority in seeking to restore order in the Arabian Peninsula state, salvage an economy that has not been able to prevent starvation in some remote regions, and usher disparate political and communal groups into a dialogue.

Hadi said that he had sometimes faced pressure from what he called intermediaries to open dialogue with AQAP and Ansar al-Sharia, an apparent reference to conservative Salafi clerics.

Such Sunni clerics have been annoyed by Hadi's willingness to open up to Shi'ite Islamists of the Houthi movement, a militia which controls some areas of north Yemen and is being included in the political transition.

The U.S. ambassador to Yemen praised Yemen's fight against al Qaeda in comments to Reuters this week. He said the government was more effective now than at any time since 2000, when a bomb attack on the USS Cole in Aden port killed 17 U.S. servicemen.

Militants have hit back since they were ousted from Abyan with a string of attacks on security officials and a suicide attack on a military parade in May that killed 100 soldiers.

(Editing by Mark Heinrich)