Allah loves not the treacherous. He had entered into pacts with several tribes, however, some of them proved themselves treacherous. Whenever he received intelligence reports about enemies gathering near his borders he carried out preemptive strikes, broke their power and dispersed them. But it may happen that you dislike a thing which is good for you, and it may happen that you love a thing which is bad for you. And Allah knows and you know not.
Persecution is worse than killing.
During his stay in Makkah he used non-violent methods and after the establishment of his government in Madinah, by the permission of Allah, he used armed struggle against his enemies whenever he found it inevitable. Once free, individuals in the society were then free to chose Islam or not. For example, after the repeated call by the oppressed people of Spain to the Muslims for help, Spain was liberated by Muslim forces and the tyrant rulers removed. The defeated rulers of Syria were Roman Christians and Iraq was ruled by Zoarastrian Persians. Muslims should remove tyranny, treachery, bigotry, and ignorance and replace them with justice and equity.