Religion is for Allah 2:193
Fight them with force until there is no test or affliction and the submissiveness, obedience and worship are for Allah. But if they desist their assault and move away from the idolatry then you do not act unlawfully against them by assaulting or killing them except the oppressors, those who exceed to the extent with unbelief or moral depravity. Prophet Muhammad came to promote the freedom of religion so that a person could have his or her 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 are saying means " the most dominant" actually means the most apparent or visible or popular.