Jordan's King Hussein was concluding his visit Friday with an agreement to keep working with the United States to bring about Arab-Israeli negotiations, diplomatic sources said.

Although Hussein stood by his decision of not interfering with the Palestine Liberation Organization's representation of the Palestinians in Israeli-occupied lands, Hussein said Jordan will keep a seat at any future Arab-Israeli negotiations, since Jordan has the longest border with Israel of any Arab country.Officials with the Jordanian party accompanying Hussein said he was close to a decision to cut short the visit Wednesday because of riots in several southern Jordanian towns, but he decided to adhere to his schedule when security forces contained the violence.

Thursday, Hussein appeared to soften his public opposition to a plan for local elections in the Israeli-occupied territories, but insisted such voting would be acceptable only as part of an overall solution.

Hussein, speaking to reporters after two hours of meetings with Secretary of State James Baker, said he was "happier and more optimistic" about the peace process than he had been for many years.

"I believe we are on our way" to progressing toward solving the Arab-Israeli dispute.

Asked by a reporter if he opposed an Israeli plan for local elections in the West Bank and Gaza Strip, Hussein said, with Baker standing at his side, "It is not for me to accept or reject the idea."

But he added, "Elections can be an element within the context of a total leading to a solution to the problem. It is not an end in itself."

A Jordanian official traveling with Hussein said the king was optimistic mainly because of the shifts he has seen in the Palestinian and Arab positions leading to possibilities of negotiations with Israel.

The official said, "It used to be the PLO which stood in the way of negotiations. Now it is (Israeli Prime Minister Yitzhak) Shamir."

During his meetings Wednesday with Baker and President Bush, Hussein expressed general support for the administration's attempts to revive the Middle East negotiations, but had specific objections to a plan for Israeli-supervised elections on the West Bank and in the Gaza Strip.