Overall meaning :
Therefore, when you, believers, engage in battle with the unbelievers, strike off their heads and, when you have completely subdued them, firmly bind those of them you have taken captive. You may then set them free either by an act of grace or against ransom. Do as you are commanded, and continue to so until the war between you and your enemies comes to an end.
Thus has Allah commanded you. Know that had Allah willed, He could have exacted retribution from them and defeated them Himself even without a fight; however, he has enjoined you to fight them so that He may test you by means of one another, thus distinguishing those with strong faith from those with weak faith.
As for those who are martyred fighting for His cause to make His religion reign supreme, never will He let their good deeds be in vain. He will guide them and set their affairs aright, and He will admit them into Paradise which He has made known to them: They will be guided to their dwellings in it even without asking to be shown the way.