CAIRO -- After a last minute change of candidates, Egyptian Foreign Minister Nabil Elaraby was elected the new secretary-general of the Arab League.

The 22-member Arab organization chose Elaraby to replace Amr Moussa, a former Egyptian foreign minister who has said he will run for the office of president in Egypt. Moussa, who is 73, has held the post for a decade.

The choice for head of the Arab League traditionally is agreed in advance, but this year, Egypt and Qatar both put candidates forward.

Egypt had nominated a member of the party of former Egyptian President Hosni Mubarak, who was ousted in February in a popular uprising. On Sunday, it substituted Elaraby, 76, a popular diplomat who backed the uprising that ousted Mubarak's regime.

After the change of candidates was disclosed, Qatar withdrew its candidate, effectively giving the job to Elaraby.

Qatar's foreign minister, Hamad bin Jassim, said Egypt's choice of Elaraby "encouraged" his country to withdraw its nominee, diplomat Abdul Rahman bin Hamad al-Attiyah of the Gulf Cooperation Council.

"We had agreement in appreciation of Egypt and the revolution of Jan. 25 (so) Qatar withdrew its candidate," he told the Arab League meeting. "This is the right choice, which encouraged us to support it."

Elaraby told the session that he came to the meeting without a prepared speech, saying he wasn't expecting to be nominated or elected. He thanked Qatar for agreeing to withdraw its candidate.

"It is my pleasure to have this precious trust in me from the council and be named as the League chief," he said.

He praised Moussa and said the Arab League faces many challenges.

"I take on this difficult job as the Arab nations are facing many problems," Elaraby said.

Egypt, which is home to the Arab League headquarters, has traditionally tried to give the top post to one of its diplomats. Only when Egypt was boycotted by other Arab members for its 1979 peace deal with Israel did a diplomat from another country get the job.

The pan-Arab organization is an umbrella group of countries in the region and tries to reach consensus on political and social issues. It has observer status at the United Nations and recently joined a number of countries in urging the U.N. Security Council to impose the no-fly zone on Libya.

Although the Arab League often has been more a place for disagreement than for action, many activists are hoping the League will play a more active role in coordinating Arab policies and pushing for reform following the uprisings in the region.

Egypt's original candidate was Mustafa el-Fiqqi, a member of Mubarak's ruling party who resigned after the popular uprising against the government began on Jan.25. Reform activists had opposed his nomination.

Arab diplomats were divided over el-Fiqqi's nomination, with some pointing out that he never held a senior diplomatic position.

Scores protested outside the League against el-Fiqqi. The crowd cheered when the media reported that el-Fiqqi was out as Egypt's candidate.

Elaraby was Egypt's U.N. representative in the 1990s and served as a judge on the International Court of Justice in The Hague between 2001 and 2006. He was a legal adviser to Egypt's Foreign Ministry during the Camp David peace negotiations with Israel that led to the peace treaty; he also participated in the negotiations to end the dispute with Israel over Taba, which ended in arbitration that turned the area over to Egypt.

Elaraby, an arbitration expert, was critical of the Mubarak government's crackdown against the uprising and was a member of a committee to advise protest leaders on their reform demands.