Religion is for Allah 2:193
Fight them with force until there is no test or affliction, and submissiveness, obedience and worship are for Allah. But if they desist their assault and move away from idolatry then you do not act unlawfully against them by assaulting or killing them except the oppressors, those who exceed to the extent of unbelief or moral depravity.
Prophet Muhammad came to promote the freedom of religion so that believers could have a relationship with G-d in their own religion, pray, go to their place of worship, and not be hindered or disturbed.
The Muslims were to fight those who persecuted the religion, mainly the idolaters, until religion was free for G-d. Some think that Muslims are to fight until Islam becomes the dominant religion. The learned in the religion do not agree with this kind of interpretation. The word given in the Qur'an that some say means "the most dominant" actually means the most apparent or visible or popular.