When the Jewish police and religious authorities arrested Jesus, they set up a kangaroo court and convicted him to a death sentence, but being under Roman rule which reserved the death penalty to Roman courts, they then took Jesus to Pilate to push injustice through the Roman court system.
Pilate, recognizing the affair as being of local Jewish concern, sent Jesus to the lower court of King Herod, rather than wasting the higher court's time on a minor matter.
Herod, however, couldn't get anywhere with Jesus, and sent Jesus back to the higher court of Pilate.
Pilate couldn't find any justification for the death sentence, so he tried various methods of calming down the Jewish rioters and releasing Jesus, even going so far as to beat Jesus to fatal lengths, which technically wasn't a death sentence, but was so in practical terms. Jesus was at this point a dead man walking. As such, he was presented bloodied, weak, and dying, to the rioters as "the man" (John 19:5).
But even that wasn't good enough for the rioters; they wanted him crucified, tortured, hanging from a cross for expected days. So they pressured Pilate more, and inadvertently scared him with the magic words "Son of God" (vv. 7-8).
So Pilate took Jesus back into the governor's headquarters for further questioning, becoming even more convinced that he simply must get Jesus released. But nothing he did satisfied the rioters.
His final attempt was to depose Herod, and make Jesus the king of the Jews. The next time Pilate presented the dying Jesus to the mob, he announced, "Here is your king!" (v. 14). (This can't have made Herod happy, even though Jesus' reign would be short-lived due to his almost-certain impending death from his earlier beating.)
But even that was not suitable to the mob; they wanted Jesus crucified, and they rejected Jesus as king, announcing they had no king but Caesar (v. 15), which just a few hours prior would have probably been considered by the Jews to be treasonous language.
So Pilate gave in, and had Jesus executed by crucifixion. But he still had the last word; on the cross, Pilate affixed a sign that said in three languages, "Jesus the Nazarene, The King of the Jews" (vv 19-20).
What Pilate probably did not intend, and what probably riled the Jews up even further, is that this phrase, as I understand it, in (Englicized) Hebrew, is rendered:
Yahshua Hanatzoi Wehemelech HayuhadimFrom a distance, the first letters stand out: YHWH
Pilate has just declared Jesus to be YHWH God, King of the Jews.
When the Jews object to the sign, wanting it changed, I can just see the smirk on Pilate's face as he responds to these trouble-makers: "What I have written, I have written" (v. 22).