The Quran describes the righteous as people who feed the needy, the orphan and the captive out of love for Allah, wanting no reward or thanks. The Prophet ﷺ said, 'Free the captive, feed the hungry and visit the sick.' He also forbade mutilation, and he taught that no one may punish with fire except the Lord of the fire. Torture, humiliation and killing a prisoner in anger therefore have no place in Islam.
A well-known example is Thumama ibn Uthal, a man of the Banu Hanifa tribe whom the Prophet's horsemen captured and brought to Medina. He said afterwards that no face on earth had been more hated by him than the Prophet's. He was tied to a pillar of the mosque. The Prophet ﷺ came to him three days in a row and asked what he had to say. Thumama said that if he was killed, a life would be taken, and if he was shown kindness, he would be grateful. On the third day the Prophet ﷺ ordered him freed. Thumama then went, washed and declared his faith of his own accord.
It should be said honestly that, like other societies of the past, Muslim armies took captives, and classical jurists discussed several options for them and differed about the details, including enslavement, which is discussed in the question about slavery. Many modern Muslim scholars hold that today's conventions that protect prisoners are in line with the Islamic ethic and that enslaving prisoners is no longer allowed, though scholars explain the older rulings in different ways.