CAIRO — Egypt and Turkey are forging an alliance that showcases two Islamist leaders maneuvering to reshapea Middle East gripped by political upheaval and passionate battles over how deeply the Koran should penetrate public life.

The relationship may foreshadow an emerging regional order in which the sway of the United States gradually fades against Islamist voices no longer contained by militaries and pro-Western autocrats.

Each country has a distinct vision of political Islam, but Turkey, which straddles Europe and Asia, and Egypt, the traditional heart of the Arab world, complement each other for now. Turkey's strong economy may help rescue Egypt from financial crisis, while Cairo may further Ankara's ambition to rise as a force among Islamic-backed governments.

What bonds and rivalries may ensue is unclear, but they are likely to affect what rises from the bloodshed in Syria, the influence of oil nations in the Persian Gulf, future policies toward Israel and the volatile divide between moderate and ultraconservative Islamists. The nations offer competing story lines playing out between the traditional and the contemporary.

"Turkey has done a good job so far of balancing the relationship between the religion and state. It is secular," said Ahmed Abou Hussein, a Middle East affairs analyst in Cairo. "This is not the case in Egypt. We haven't found the balance between religion and state yet. We're all confused, not only the Islamists."

The two countries recently conducted naval exercises in the Mediterranean Sea. Egyptian President Mohamed Morsi visited Ankara in September and Turkish Prime Minister Recep Tayyip Erdogan is expected to arrive in Cairo this month with promises of closer cooperation and a financial aid package that may reach $2 billion.

"Our history, hopes and goals bind us together to achieve the freedom and justice that all nations are struggling for," Morsi said on his trip.

The nations' deepening ties come amid international and domestic pressure emanating from revolutions that are recasting political rhythms in the Middle East and North Africa.

Erdogan is moving to fashion Turkey's democracy into a model for Arab governments even as he has been criticized by human rights groups for the arrest of thousands of Kurdish activists. Morsi is seeking to restore Egypt's global stature after years of diminishment under deposed leader Hosni Mubarak.

Turkey's diplomatic finesse and economic allure have allowed it to deftly exert its regional influence. But the civil war in Syria has shredded relations between Ankara and Damascus and left Erdogan, who has threatened Syrian President Bashar Assad with wider military action, searching for a plan to end the conflict on his border.

Turkey has also drawn the ire of Iran, a Syrian ally, for signing on to a U.S.-backed missile shield. And Iraqi Prime Minister Nouri Maliki this year called Turkey a "hostile state" and accused it of agitating sectarian tension in his country.

Erdogan, who learned his wiles as a boy selling sesame buns on the streets of Istanbul, is more flamboyant than Morsi, the son of a peasant farmer. But Morsi has proved a canny politician: In a visit to Tehran in August, he signaled a thaw in Egyptian-Iranian relations while at the same time angering Iran by condemning Assad's crackdown on dissent.

Egypt's deeper problems bristle on the home front, including unemployment, poverty, crime and decrepit state institutions that became more glaring after last year's overthrow of Mubarak. Both Morsi and Erdogan, who rose to power nearly a decade ago, curtailed the political influence of their nations' generals, but each has been accused by secularists as having authoritarian streaks tinged with Islam. The countries have a tendency to harass and arrest dissidents and journalists.

A closer fusion of Cairo and Ankara stems in part from the influence Egypt's Muslim Brotherhood had on Islamist organizations across the region, including Erdogan's Justice and Development Party. While the Brotherhood was being persecuted by Mubarak, a brash Erdogan riveted the "Arab street" with his populism and chiding of leaders, such as Mubarak, for their compliance toward the West.

The question is, how will Erdogan and Morsi maneuver the politics of a Middle East that both want to influence, and which Egypt regards as its historic and strategic territory?

"I don't think Egypt even under the Muslim Brotherhood would appreciate a Turkey that would nose around on Egypt's political turf," said Kemal Kirisci, a professor of political science and international relations at Bogazici University in Istanbul.