The presence of Islam in Latvia was first recorded in the early 19th century. The Muslims had mainly Tatar and Turkic backgrounds, and most had been brought to Latvia against their will. These included Turkish prisoners of war from the Crimean War and the Russo-Turkish War of 1877. After the Russo-Turkish War almost one hundred Turkish prisoners were brought to the town of Cēsis, where nearly 30 perished owing to harsh conditions of weather, under no suitable location for warmth and no protection for cold.
Conversion to Islam is growing fast among native Latvians.
In 1902, a Muslim congregation was officially established and recognized by the government. The community elected Ibrahim Davidof as its leader and a prayer hall was inaugurated. The majority of Muslims residing in Latvia in the early part of the 20th century were conscripted in the Russian army. After release from service, most would leave for Moscow. Many Muslims residing in Latvia on permanent basis were ordered to be arrested by Czarist Russia during World War I. The Czarist regime cited security reasons, claiming they were of Turkish origin and could pose a security threat as Ottoman Turkey was fighting Russia in the war. Most were taken to Moscow.
During the creation of the Soviet Union and amid civil war, many refugees entered Latvia, including Muslims of various ethnicities. They were however known to Latvians as Turks. In 1928, Husnetdinov, a Turkic priest, was elected leader of Riga Muslim community. He held that post until 1940.