In the Sermon on the Mount, Jesus says:
You have heard that it was said 'an eye for an eye, and a tooth for a tooth.' But I tell you: don't resist an evil person. Rather, whoever slaps you on the right cheek, turn to him also the other. And whoever wants to sue you and take your shirt, give to him also your coat. And whoever charges you to go one mile, go with him two. Give to the one who asks, and do not refuse the one who wishes to borrow from you.
He goes on to say:
You've heard that it was said: 'Love your neighbor, and hate your enemy.' But I tell you, love your enemies and pray for those who persecute you, so that you may become sons of your Father who is in heaven. For He makes His sun rise upon the malicious and the benevolent, and makes it rain upon the just and the unjust. For if you love those who love you, what have you really done worth mentioning? Do not the tax collectors also do the same? And if you greet your brethren only, what exceptional thing have you done? Do not the gentiles do the same? So then, be holistic as your heavenly Father is holistic.
In Matthew's teaching on retaliation, Jesus quotes Ex 21:24. Mainly because of Jesus' reference to this passage, many people mistakenly see this as a dichotomy between the Old and the New. The Old Testament teaches retaliation, while the New teaches forgiveness. That's way off to left field, though. This law forbids turning justice into vengeance, an execution into a bloodbath. What happens if someone insults the mafia? Do they just insult you back? No; they'd kill you. What happens if you kill a member of the mafia? They'd kill you, your pets, your family, and everyone you've ever had a crush on. The natural instinct is to hurt someone much worse than they hurt us, and this law actually forbids that.
"Eye for an eye" is not the ideal response, but enforcing this limit of vengeance will prevent people from committing worse sins. The point of this law is that the punishment may not exceed what the crime merits (so the poor are not overpenalized) and it may not fall below what the crime merits (so the rich do not escape with a slap on the wrist). To quote Alexander Hamilton's Handbook on the Pentateuch: "What Jesus does in the Sermon on the Mount is elevate the response to evil beyond the concern for simple justice to voluntary assistance for the oppressor" (p. 206).
Then He specifically points out the godly response to public humiliation (the Greek verb in this context means a slap to the face, though the word is also used of roughing someone up), being taken to court, and enforced labor. No matter what sort of person wishes to borrow from you, you are supposed to give.
Now, Jesus quotes Leviticus 19:18, which says to love your neighbor. That chapter elaborates that one must love strangers/sojourners/foreigners as oneself, also. Interestingly, the Dead Sea Scrolls add to Lev 19:18 "...and hate your enemy." As if such a thing ever needed to be taught! Hating one's enemies is just common sense.
Jesus, however, considers hating one's enemies as something that needs to be untaught. What is our purpose in doing this? "So you may become sons of your Father who is in heaven." In this use, "son" means more than just parent-child relationship: here it means resemblance/imitation of your Father (this is a subset of the "members of a category" usage of "son"). By loving our enemies, we resemble our Father in heaven. Well Jesus, how does that work? How does God love His enemies?
"He makes his sun rise upon the malicious and the benevolent, and he makes it rain on the just and the unjust." Hmm. So, God allows sun and water to reach the crops and cattle of even those hostile to God? God actually gives the same life support to them? Well Jesus, good point. Loving those who love us does not necessarily reflect the change that comes from following after the Lord, nor does fellowship/greeting to our friends and relatives.
So, Jesus: God's love is universal, because he gives life to even those hostile to Him. What about us? What should we do, Jesus? "So then, be holistic as your heavenly Father is holistic." Let me explain why I prefer "holistic" to "perfect" here. Jesus' point is not that we must know exactly how to provide flawlessly and perfectly for each and every person even when we just met them. Only God can do that. Rather, His point is that we must be all-encompassing and indiscriminate in our love, giving it to everyone. Note once again that the example of God's love for His enemies is that he grants them life instead of either actively killing them or passively permitting them to starve. Oh, and I also prefer "holistic" because I am not translating on the 8th-grade reading level, as the (T)NIV does.
Luke's quote, in context, is also quite interesting. In 6:20-26, Jesus pronounces blessings upon those who are poor, those who suffer, those who are wronged. "You are blessed when the people hate you and when they single you out and treat you with reproach and throw away your name as evil for the sake of the Son of Man" (think of something gross that you'd reflexively throw off if you touched it). Jesus goes on to explain that the same happened to the prophets, whereas the people loved and applauded the false prophets who claimed that the Lord was with them all the time. Now Luke puts forth the love-for-enemies passage, and he even inserts the teaching about retaliation inside the love-for-enemies section.
But I tell you who hear: love your enemies, do good to those who hate you; bless those who curse you, pray for those who insult you. To the one who strikes you on the cheek, turn also the other, and do not refuse [to give] your shirt to whomever asks for your coat. Give to everyone who asks, and do not demand it back. And however you wish people to treat you, treat them likewise. For if you love those who love you, what special thing have you done? For even the sinners love those who love them. And if you show benevolence to those who show you benevolence, what special thing have you done? The sinners do the same thing, too. And if you lend to those from whom you expect repayment, what's special about that? Sinners also lend to sinners expecting to receive back their own things. Nevertheless, love your enemies and show benevolence and lend without expecting anything back. Thus will your reward be great, and you will be sons of the Most High, for He is kind to the ungracious and malicious. Be compassionate just as your Father is compassionate.
Jesus blesses his audience "you who are poor," and "who hunger now" and "who cry now" (reference to fasting and weeping, perhaps?). He then tells us, the audience, that we are actually blessed when we suffer abuse. He does not say to resist such things. Actually, the fact that he points to our reward for suffering instead of specifically saying how to react implies that he expects us to, not necessarily welcome it, but certainly endure it. For doing so, we will be counted among the prophets.
Lest anyone say I avoid the prophetic woes section: Jesus then addresses the "rich" as if they were present, though they are not. The "rich" are those who do not listen to Jesus' message of radical service to God, and who instead are so blinded by the religious establishment's status quo that they do not see the need for immediate and decisive action to further the Kingdom of God.
Now, Jesus switches back to the blessed "poor," his disciples. This passage is similar but not identical to Matthew's parallel. Luke says to turn the other cheek to the one who strikes you -- this is not a backhanded slap of humiliation, but an act of violent aggression. Luke flavors this passage to show it in the light particularly of giving alms to the poor (a point that Matthew emphasizes just shortly after his parallel for this). Another difference in Luke is that instead of giving God the holistic attribution, he says that God is good/kind. For what that word means, read 1 Chr 16:34 or start reading the book of Psalms from chapter 100 to 136. When it says that God is good/kind, it also says "His love endures forever." To understand what Luke means in verse 36 about being "compassionate, just as your Father is compassionate," read Jonah 4:4 or Joel 2:13. That is what we must imitate if we are to be sons of the Most High.