Danish historian Jørgen Bæk Simonsen documents that encounters between Denmark and the Muslim world date back to the Middle Ages when the Danish military participated in the Crusades to take control of Jerusalem from Muslim rule. King Frederick V of Denmark also travelled to South Arabia to collect information, plants, and artifacts. Among his co-voyagers was Carsten Niebuhr who observed and noted the customs of the region. One of the first Danish converts to Islam was Knud Holmboe, a journalist and writer of Desert Encounter, in which he detailed his first-hand account of the Libyan Genocide.
An 1880 Danish census recorded 8 "Mohammadans" in the country. Censuses continued to be carried out until 1970. Large scale immigration from Muslim countries began in the 1950s. The first purpose-built mosques belonged to Ahmadi Muslims and was constructed in 1967. In 1973, the Danish government stopped free migration to the country. Rules were laxed in 1974 so that people with family in Denmark, people marrying someone in Denmark, or people seeking asylum could come to the country.
Freedom of religion is guaranteed by the Constitution of Denmark, but the Church of Denmark enjoys certain privileges such as state subsidies that other religious groups in the country do not. As of 2013, 23 different Muslim communities are recognized as "acknowledged religious communities," giving them certain tax benefits.
The asylum seekers comprise about 40% of the Danish Muslim population.
In 2014 halal slaughter without electrical stunning was banned in Denmark citing animal welfare concerns.
In August 2017, two imams, one of which is the head of Hizb ut-Tahrir in Australia were added to the Danish list of hate preachers which meant they could not enter Denmark, bringing the total to ten. The list also comprised Salman al-Ouda and Bilal Philips.
In autumn 2017, the Danish parliament (Danish: Folketinget) agreed to adopt a law prohibiting people to wear "attire and clothing masking the face in such a way that it impairs recognizability". A full ban on both niqabs and burqas was announced on 31 May 2018. The ban came into force on 1 August 2018 and carries a fine of 1000 DKK, about 134 euro, by repeat offending the fine may reach 10 000 DKK. Then targets all garments that covers the face, such as fake beards or balaclavas. Supporters of the ban claim that the ban facilitates integration of Muslims into Danish society while Amnesty International claimed the ban violated women's rights. A protest numbering 300-400 people was held in the Nørrebro district of Copenhagen organised by Socialist Youth Front, Kvinder i Dialog and Party Rebels.
According to polls among Muslims in Denmark conducted in 2006 and 2018, religiosity shows an escalation over time, whereas 37% prayed five times a day in 2006, by 2018 this number had increased to 50%. This was contrary to expectation where Muslims had been expected to conform to mainstream Danish society where not many people are not particularly devoted to religion. The possible cause of the trend, according to sociologist Brian Arly Jacobsen at Copenhagen University was that in the construction of 20-30 new mosques in the intervening 10 years.
In April 2019, riots broke out in Nørrebro in Copenhagen, Denmark, after Islam critic Rasmus Paludan staged a demonstration in the district. 23 people were arrested for a range of offences, from refusal to obey commands issued by police, arson and violence against police. Emergency services responded to 70 fires connected to the disturbances.