Hardly a day goes by that an Iranian official doesn’t threaten Turkey. Take for instance Maj. Gen. Yahya Rahim Safavi’s recent warning to Ankara: “Turkey must radically rethink its policies on Syria, the NATO missile shield and promoting Muslim secularism in the Arab world, or face trouble from its own people and neighbors.”

This is no surprise. Turkish-Iranian rivalry goes back centuries, to the Ottoman sultans and the Safavid shahs. It briefly subsided in the 20th century, when Turkey became an inward-looking nation-state, leaving a vacuum in the Middle East. In the past decade, though, Turkey’s economic growth and emergence as a regional giant under the Justice and Development Party, or A.K.P., have revived its standing. From the Syrian uprising to Iraq’s sectarian convulsions to Iran’s push for nuclear power, Ankara is the main challenger to Tehran’s desire to dominate the region.

Following the A.K.P.’s ascent to power in 2002, the Turks were, initially, not interested in competition with the Iranians and relations between Ankara and Tehran seemed quite warm. Both countries defended the Palestinian cause. Ankara did not appear threatened by Iran’s nuclear project. High-level visits between the two governments became routine and trade boomed.

Meanwhile, shared objections to the Iraq War appeared to bind the Turks and the Iranians. Iran even stopped harboring rebels of the Kurdistan Workers’ Party, or P.K.K., which it had encouraged to attack Turkey because of Ankara’s pro-Western stance. After the Iraq War, Tehran began bombing the very P.K.K. camps it had earlier permitted on its territory, winning points with the Turks.