Cairo is reaching out to Iran and the militant group Hamas, a new agenda that angers Israel and will pose a challenge to U.S. ties as it threatens to upend the balance of power in the Middle East.

Reporting from Cairo — Egypt's new government has embarked on adventurous diplomacy to replace the legacy of former President Hosni Mubarak with a bolder Middle East presence less compliant with the U.S. and Israel.

Cairo's maneuvers to reshape foreign policy include improved relations with the militant group Hamas, which controls the Gaza Strip, and its decision to ignore Israeli objections and reopen the Rafah border crossing after years of blockade to stop weapons smuggling into the Palestinian enclave. Egypt also brokered the reconciliation pact signed last week between Hamas and its Palestinian rival, Fatah, to cooperate on an independent homeland.

Those moves come as Cairo is working to restore diplomatic ties with Iran, a country that the U.S. regards as a persistent threat to regional stability. This new agenda has angered Israel and is an indication that Egypt's emerging diplomacy will test allies and enemies on sensitive matters that could upset the balance of power in the region.

Such assertiveness following the political uprising that swept Mubarak from office in February comes as the country's dominance in the region had slipped, with Persian Gulf nations rising in stature and much of the Arab world criticizing Egypt for its close ties to Israel. The country is being run by a military council, which oversees a caretaker civilian Cabinet, until parliamentary and presidential elections are held this year.

The new attitude echoes through recent statements by Egyptian officials. Foreign Minister Nabil Elaraby has called "shameful" Egypt's decision to close the Gaza border in 2007. Such a description would never have been publicly uttered under the Mubarak government. It is a sign the leadership is readjusting international policies to be more in line with public sentiment. The Rafah crossing is expected to reopen soon.

Cairo's 1979 peace treaty with Israel remains unpopular in Egypt. Islamic ultraconservatives, whose voices have grown louder since the fall of Mubarak, have called for scrapping the treaty. That is unlikely given the shared economic interests between the two countries and the prospect that such a move could jeopardize the $1.2 billion Egypt receives in annual aid from the United States. But Israel has grown increasingly irritated by Cairo's actions.

"We are witnessing a sequence of Egyptian moves that do not bode well, including comments that the Camp David agreements have run their course and public opinion polls showing support for undoing the peace treaty," Israeli Vice Prime Minister Silvan Shalom told Israel Radio. "We must prepare for change in reality concerning Egypt and indeed the Middle East."

Egypt's leading role in the reconciliation deal between Islamist Hamas and the more secular Fatah was another sign of Cairo's nuanced diplomacy. The two Palestinian factions had been estranged since 2007. Former Egyptian intelligence chief Omar Suleiman negotiated for years to bring them together. Cairo's suspicions of Hamas, however, kept the atmosphere strained.

Egypt's new Foreign Ministry took a more balanced stance. The unity pact was further propelled by other pressures. Hamas' key supporter, Syria, is preoccupied and convulsed by protests while Fatah's ally, Mubarak, is gone.

"Egypt was clever to take advantage of what's happening now," said Mustafa Labbad, head of the Al Sharq Center for Regional and Strategic Studies. "Egypt's role in this reconciliation is a matter of national security rather than a change in its political ideology."

The development is a setback for the government of Israeli Prime Minister Benjamin Netanyahu, which fears that Hamas, considered by the U.S. and Israel as a terrorist organization, could become a well-armed instigator within a new Palestinian state.

One Israeli official, who asked not to be named because of the sensitivity of the matter, said Israel was pressing the U.S. and Europe to caution Egypt on its dealings with the Palestinians: "In our conversations with members of the international community, we are saying that it's very important that they be clear and unequivocal in the way they express their expectations to the Egyptian government."

Egypt's efforts to normalize relations with Iran also worry Israel. Egypt and Iran broke diplomatic ties during Iran's 1979 Islamic Revolution. Cairo has since blamed Tehran for meddling in Arab affairs and for exploiting tensions by backing Hamas and the militant group Hezbollah in Lebanon.

Mubarak's government began talks with Iran, but little came to fruition, especially as Arab countries grew anxious over Iran's nuclear program. In recent weeks, however, Egypt has refocused its negotiations and announced it wants to "open a new page" with Tehran.