“When Jesus had received the sour wine, he said, "It is finished," and he bowed his head and gave up his spirit” (John 19:30 ESV).
On the surface, the accounts of Luke and John certainly might seem to be at variance with each other regarding the last words of Jesus, but when we look more closely we find little reason to see any contradiction.
First, we should notice that while Luke specifically says “…having said this he breathed his last,” the wording of John’s Gospel “… and he bowed his head and gave up his spirit” does not necessarily preclude intervening words – it could simply mean that moments or minutes after receiving the wine, Jesus died.
Note that while Luke focuses specifically on Jesus’ last words – and calls them exactly that – John seems to focus on the sour wine event and its resultant “It is finished” as the final prophecies fulfilled by Christ. This is typical of Luke’s frequent focus on the humanity of Jesus and his actual words, as opposed to John’s focus on Jesus’ fulfillment of prophecies relating to the Messiah and details regarding the message of salvation.
But there is no real reason to think that both accounts were not true. Jesus’ last words may have been a combination of what John and Luke record: “It is finished. Father, into your hands I commit my spirit.” If these were the actual and full last words of Jesus, then the two Gospel writers simply recorded that part of the expression which was of most importance to their own accounts.
It is also sometimes said that both Luke and John are contradicted by Matthew and Mark, whose Gospels both record Jesus’ expression “My God, my God, why have you forsaken me?” as his last words. But both Matthew and Mark write that, soon after this, Jesus gave a loud cry: “And when Jesus had cried out again in a loud voice, he gave up his spirit” (Matthew 27:50); “With a loud cry, Jesus breathed his last” (Mark 15:37).
But these accounts do not say whether the “loud cry” or “loud voice” contained words or not. If the cry contained words, it was doubtless those recorded by Luke and John. The reason that the other two Gospels say a “voice” or “cry” was probably because they are based on the account of a witness of the crucifixion who was close enough to hear the cry, but not close enough to make out the exact words. (Both Matthew and Mark agree that many of the witnesses stood “at a distance” from the cross – Matthew 27:55, Mark 15:40).
When we keep both factors in mind: that Luke and John compiled their Gospels stressing different themes, and that Matthew and Mark may well have drawn their information from different witnesses, there is no need to presume any contradiction between the four Gospels as to the last words of Jesus.