The Iranian Safavids were Shia Muslim, while the Ottoman Turks were Sunni. This division between Muslims dates back to the beginning of Islam, when two groups of Muslims split over which leader should succeed Muhammad upon his death.
The Safavid Empire began in the 13th century in Persia when the Safaviyya Sufi, led by Safi-ad-din Ardabili, became prominent. Safi-ad-din and his heirs unified Persia, then took over large regions stretching from Pakistan to Turkey. Under the Safavid Empire, Persia once again became the dominant link between the Eastern and Western trading worlds.
Both the Safavids and the Ottomans, as well as the Indian Mughals, were "gunpowder empires," using advanced gunpowder-based weaponry to expand their influence. Once the two empires came in contact, the Turks and Safavids fought over Iraq for over a century, with no one an apparent victor. This led to the Safavids allying themselves with the West against the Turks, a common enemy to both. Over time, the Safavids found it expedient to tolerate Western Christianity and expedite trade, an arrangement that benefited both regions.
All three gunpowder empires ultimately declined with the rise of European naval dominance during the 16th and 17th centuries. So long as the Europeans were confined to land trade routes, the three Muslim empires could control their movements in the East. However, when superior European ships began trading and then making war in the Indian Ocean, their incursions led to the weakening and then decline of all three empires.