For purposes of discussion, the period known as the "Middle Ages" ran from 476 A.D. to 1453 A.D., the year of the fall of Constantinople to Islam and the consolidation of the Ottoman Empire.
From its birth as a religious and political movement in the 7th Century to the end of the Middle Ages, Islam spread over vast territories throughout Arabia and across much of the world. Islam spread to the Iberian Peninsula and across northern Africa to the West and all the way to current day Indonesia and to the Philippines in the East. During the course of the Middle Ages, followers of Islam waged many battles both in the interest of Islam's spread and in defense of those territories it had conquered. There were military victories and defeats. The death of Muhammad spawned a split among Muslims over the question of the prophet's rightful heir that remains the inspiration for much violence among Muslims today (i.e., the split between Sunni and Shia).
In order to understand the spread of a religion as a political movement, one needs to view that religion from different spots on the spectrum of religious orthodoxy. The more orthodox the believer, the more committed the individual to the role of that religion in government. Salafist Sunni Muslims, for example, believe that Islam should be practiced as it was in the time of Muhammad in the 7th Century. Similarly, many Shia believe in a particularly puritanical form of Islam, although, as with Sunnis, the level of orthodoxy in practice varies widely.
The one thing all Muslims believe to one degree or another is that the Quran is the word of God, and that the Quran alone provides the basis for law and governance. Dictates not derived from the Quran carry neither moral nor political weight. Consequently, as Islam spread, Islamic law became more prevalent throughout territories under its control. [It should be noted here that many Muslims living in countries with forms of government not grounded in Islam respect the laws and leadership of those countries. The religious role in their daily lives is subject to self-imposed restrictions consistent with their desire to assimilate into the larger society. During the Middle Ages, however, practices tended toward stricter application of religious tenets.]
The application of Quranic law varied widely over time and across geographical expanses. The most successful Islamic empire was the Turkish Ottoman Empire, which would last from its inception in the late 13th Century to its final dissolution following the end of World War I. While strongly Islamic, the Ottomans were also known for being lenient in allowing the practice of non-Islamic religions in territory under their control. The strict Wahhabi or Salafi interpretation of Islam that emerged in the 18th Century (and, hence, outside the parameters of this discussion) would set much stricter standards in the practice of the religion and its role in politics and law.
In conclusion, the military prowess of individual Islamic leaders and the commitment of their followers allowed for the steady spread of the religion across much of the globe. Islamic tenets appealed to many of those who fell within territories captured by Muslims; many others were forcibly converted to Islam. Either way, the spread as both a religious and political movement involved much violence and much persuasion.