Surah Nisa Verses 92-100
These battles were against the polytheists who were declared to be annihilated. Therefore their killing in the battlefield was allowed. Now if a polytheist did not want to fight the Muslims he should not join the war and should not be on the battlefield. If he was there he would be counted among them. During the battle it is not possible to stop the attack. Therefore the exception is made only for those who during the battle declared their belief in Islam. Although their declaration in such a situation is dubious that they might ave faked it just tor save their lives, still Muslims were instructed not to kill him.