Verse 9:5 speaks about a specific war with the pagan Arab tribes who had broken their treaty and attacked the Muslims. It is not an order to kill non-Muslims anywhere and at any time, as the next verses make clear.
The fuller answer
The verses before it (9:1-4) mention that treaties with the idolaters who had kept their word must be honoured until their term, and the verse itself is about those who violated the treaty. Verse 9:6, directly after it, orders: if any of them asks for protection, give it to him, and take him to a place of safety. Verse 9:7 and 9:13 give the reason: they broke their oaths and were the first to attack.
Classical scholars such as Ibn Kathir and al-Tabari read it in its setting, and many modern ones stress the same point. Taken alone, any text can be misused, and those who quote it to claim that Islam commands to kill non-Muslims ignore its context, and verses like 2:256, 60:8 and 109:6.
And when the sacred months have passed, then kill the polytheists wherever you find them and capture them and besiege them and sit in wait for them at every place of ambush. But if they should repent, establish prayer, and give zakah, let them [go] on their way. Indeed, Allah is Forgiving and Merciful. And if any one of the polytheists seeks your protection, then grant him protection so that he may hear the words of Allah. Then deliver him to his place of safety. That is because they are a people who do not know.
Allah does not forbid you from those who do not fight you because of religion and do not expel you from your homes - from being righteous toward them and acting justly toward them. Indeed, Allah loves those who act justly.
This answer follows the mainstream Sunni understanding and is general learning, not a fatwa. Where Muslims differ, the answer says so. Have a question of your own? Write to us.