The presence of Muslims 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 Turkishprisoners 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.
The total Muslim population in Latvia is estimated at about 2,000 by Pew Forum. Virtually all Muslims in Latvia are Sunni. There is also an active presence of Ahmadi.
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.
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.