Matthew 21:15: "But when the chief priests and the scribes saw the wonderful things that he did, and the children crying out in the temple, 'Hosanna to the Son of David!' they were indignant..."
Mark 11:1-11: "1 Now when they drew near to Jerusalem, to Bethphage and Bethany, at the Mount of Olives, Jesus sent two of his disciples 2 and said to them, 'Go into the village in front of you, and immediately as you enter it you will find a colt tied, on which no one has ever sat. Untie it and bring it. 3 If anyone says to you, "Why are you doing this?" say, "The Lord has need of it and will send it back here immediately."' 4 And they went away and found a colt tied at a door outside in the street, and they untied it. 5 And some of those standing there said to them, 'What are you doing, untying the colt?' 6 And they told them what Jesus had said, and they let them go. 7 And they brought the colt to Jesus and threw their cloaks on it, and he sat on it. 8 And many spread their cloaks on the road, and others spread leafy branches that they had cut from the fields. 9 And those who went before and those who followed were shouting, 'Hosanna! Blessed is he who comes in the name of the Lord! 10 Blessed is the coming kingdom of our father David! Hosanna in the highest!'
"11 And he entered Jerusalem and went into the temple. And when he had looked around at everything, as it was already late, he went out to Bethany with the twelve."
Psalm 118:25-26: "25 Save us, we pray, O LORD! O LORD, we pray, give us success!
"26 Blessed is he who comes in the name of the LORD! We bless you from the house of the LORD."
+++
The text is public domain:
Hosanna, loud hosanna,
The little children sang;
Through pillared court and temple
The lovely anthem rang.
To Jesus, who had blessed them,
Close folded to His breast,
The children sang their praises,
The simplest and the best.
From Olivet they followed
Mid an exultant crowd,
The victor palm branch waving
And chanting clear and loud.
The Lord of earth and heaven
Rode on in lowly state
Nor scorned that little children
Should on His bidding wait.
"Hosanna in the highest!"
That ancient song we sing;
For Christ is our Redeemer,
The Lord of heav'n our King.
Oh, may we ever praise Him
With heart and life and voice
And in His blissful presence
Eternally rejoice!
+++
The text from Mark is the main source (appearing most obviously in the second verse), but the hymn's first verse is drawn from the text from Matthew. The lines "To Jesus, who had blessed them, / Close folded to His breast" seem to refer to Matthew 19:13-15, where the disciples rebuke those who bring children to Jesus, but Jesus says, "Let the little children come to me and do not hinder them, for to such belongs the kingdom of heaven."
As The Lutheran Service Book notes below the hymn, Hosanna is "a Hebrew word of praise meaning 'save us now.'" This seems to be why Psalm 118 and its "Save us, we pray, O LORD!" is also cited.