The Sheep and the Goats or "the Judgement of the Nations" is a pronouncement of Jesus recorded in chapter 25 of the Gospel of Matthew, although unlike most parables it does not purport to relate a story of events happening to other characters. According to Anglican theologian Charles Ellicott, "we commonly speak of the concluding portion of this chapter as the parable of the Sheep and the Goats, but it is obvious from its very beginning that it passes beyond the region of parable into that of divine realities, and that the sheep and goats form only a subordinate and parenthetic illustration". This portion concludes the section of Matthew's Gospel known as the Olivet Discourse and immediately precedes Matthew's account of Jesus' passion and resurrection.
This story and the parable of the ten virgins and the parable of the talents in the same chapter "have a common aim, as impressing on the disciples the necessity at once of watchfulness and of activity in good, but each has ... a very distinct scope of its own".
The text of the passage appears in Matthew's Gospel and is the final portion of a section containing a series of parables.
But when the Son of Man comes in his glory, and all the holy angels with him, then he will sit on the throne of his glory. Before him all the nations will be gathered, and he will separate them one from another, as a shepherd separates the sheep from the goats. He will set the sheep on his right hand, but the goats on the left. Then the King will tell those on his right hand, 'Come, blessed of my Father, inherit the Kingdom prepared for you from the foundation of the world; for I was hungry, and you gave me food to eat. I was thirsty, and you gave me drink. I was a stranger, and you took me in. I was naked, and you clothed me. I was sick, and you visited me. I was in prison, and you came to me.'
Then the righteous will answer him, saying, 'Lord, when did we see you hungry, and feed you; or thirsty, and give you a drink? When did we see you as a stranger, and take you in; or naked, and clothe you? When did we see you sick, or in prison, and come to you?'
The King will answer them, 'Most certainly I tell you, because you did it to one of the least of these my brothers, you did it to me.' Then he will say also to those on the left hand, 'Depart from me, you cursed, into the eternal fire which is prepared for the devil and his angels; for I was hungry, and you didn’t give me food to eat; I was thirsty, and you gave me no drink; I was a stranger, and you didn’t take me in; naked, and you didn’t clothe me; sick, and in prison, and you didn’t visit me.'
Then they will also answer, saying, Lord, when did we see you hungry, or thirsty, or a stranger, or naked, or sick, or in prison, and didn’t help you?
Then he will answer them, saying, 'Most certainly I tell you, because you did not do it to one of the least of these, you didn’t do it to me.' These will go away into eternal punishment, but the righteous into eternal life.
The connection between the images of king and shepherd, recalls the figure of David. 
The two parables that precede this one (Parable of the Ten Virgins and the Parable of the Talents) stress waiting for and preparing for the return of Christ. "This parable is similar to the Rich man and Lazarus in that the time to repent and be converted, the time to care for the poor on one's doorstep, is past." It also recalls the parable of the Good Samaritan. As associate professor of Biblical Languages at Union Presbyterian Seminary, E. Carson Brisson, says, "Let it be noted that this list of afflicted and needy individuals is, at first glance, a list of the very ones who appear to be bereft of God's favor. These are ‘the least.’ These are truly ‘other.’" Also, see Ezekiel 34:4 for a similar list of afflicted and needy individuals whom God favors. This pericope is also similar to the Parable of the Wheat and Weeds which will be sorted out on Judgment Day. What distinguishes the sheep from the goats is the acceptance or rejection of Jesus' message.
There is some difference of opinion among scholars regarding the identity of "the least of these my brothers", with Reginald H. Fuller and others holding that it refers to the disciples Jesus sent out on mission. "The criterion of judgment for all the nations is their treatment of those who have borne to the world the message of Jesus, and this means ultimately their acceptance or rejection of Jesus himself; cf. Mt 10:40, “Whoever receives you, receives me.”" "For the Son of Man will come with his angels in his Father’s glory, and then he will repay everyone according to his conduct."(Mt 16:27).
True compassion will result in action. Those who believe in justification by faith may still accept that good works may function as a test or measure of belief.
According to free grace theology, this passage implies that only faithful believers are able to survive the tribulation; it draws a distinction between inheriting versus entering the kingdom.
Cornelius a Lapide in his great commentary writes, "He compares the elect to sheep, because of their innocence, modesty, humility, obedience, and patience; the reprobate to goats, because this creature has a fetid smell. It is fierce, immodest, lascivious. It walks in precipitous places. And it is quarrelsome. Such are the wicked. Wherefore under the Old Law goats were wont to be offered as sin-offerings." Lapide also notes that, "there are six principal corporal works of mercy which Christ here speaks of, viz., to feed the hungry, to give drink to the thirsty, to take in strangers, to clothe the naked, to visit the sick, to comfort and redeem captives, to which may be added a seventh, to bury the dead, which is commanded in Tobit."