From Wikipedia:
Before adopting Islam — a process that was greatly facilitated by the Abbasid victory at the 751 Battle of Talas, which ensured Abbasid influence in Central Asia — the Turkic peoples practised a variety of shamanism. After this battle, many of the various Turkic tribes — including the Oghuz Turks, who were the ancestors of both the Seljuks and the Ottomans — gradually converted to Islam, and brought the religion with them to Anatolia beginning in the 11th century.
The Ottoman Empire was, in principle, tolerant towards Christians and Jews (the "Ahl Al-Kitab", or "People of the Book", according to the Qu'ran) but not towards the polytheists, in accordance with the Sharia law. Such tolerance was subject to a non-Muslim tax, the Jizya.
Under the millet system, non-Muslim people were considered subjects of the empire, but were not subject to the Muslim faith or Muslim law. The Orthodox millet, for instance, was still officially legally subject to Justinian's Code, which had been in effect in the Byzantine Empire for 900 years. Also, as the largest group of non-Muslim subjects (or zimmi) of the Islamic Ottoman state, the Orthodox millet was granted a number of special privileges in the fields of politics and commerce, in addition to having to pay higher taxes than Muslim subjects.[33],[34]
The Ottoman Sultan Mehmed II allowed the local Christians to stay in Constantinople (Istanbul) after conquering the city in 1453, and to retain their institutions such as the Greek Orthodox Patriarchate. In 1461 Sultan Mehmed II established the Armenian Patriarchate of Constantinople. Previously, the Byzantines considered the Armenian Church as heretical and thus did not allow them to build churches inside the walls of Constantinople. In 1492, when the Muslims and Sephardic Jews were expelled from Spain during the Spanish Inquisition, the Ottoman Sultan Bayezid II sent his fleet under Kemal Reis to save them and granted the refugees the right to settle in the Ottoman Empire.
The state's relationship with the Greek Orthodox Church was largely peaceful, and recurrent oppressive measures taken against the Greek church were a deviation from generally established practice. The church's structure was kept intact and largely left alone but under close control and scrutiny until the Greek War of Independence of 1821–1831 and, later in the 19th and early 20th centuries, the rise of the Ottoman constitutional monarchy, which was driven to some extent by nationalistic currents, tried to be balanced with Ottomanism. Other Orthodox churches, like the Bulgarian Orthodox Church, were dissolved and placed under the jurisdiction of the Greek Orthodox Patriarchate; until Sultan Abdülaziz established the Bulgarian Exarchate in 1870 and reinstated the autonomy of the Bulgarian Church.
Similar millets were established for the Ottoman Jewish community, who were under the authority of the Haham Başı or Ottoman Chief Rabbi; the Armenian Orthodox community, who were under the authority of a head bishop; and a number of other religious communities as well.