Psalm 72:1-17: "1 Give the king your justice, O God, and your righteousness to the royal son! 2 May he judge your people with righteousness, and your poor with justice! 3 Let the mountains bear prosperity for the people, and the hills, in righteousness! 4 May he defend the cause of the poor of the people, give deliverance to the children of the needy, and crush the oppressor!
"5 May they fear you while the sun endures, and as long as the moon, throughout all generations! 6 May he be like rain that falls on the mown grass, like showers that water the earth! 7 In his days may the righteous flourish, and peace abound, till the moon be no more!
"8 May he have dominion from sea to sea, and from the River to the ends of the earth! 9 May desert tribes bow down before him, and his enemies lick the dust! 10 May the kings of Tarshish and of the coastlands render him tribute; may the kings of Sheba and Seba bring gifts! 11 May all kings fall down before him, all nations serve him!
"12 For he delivers the needy when he calls, the poor and him who has no helper. 13 He has pity on the weak and the needy, and saves the lives of the needy. 14 From oppression and violence he redeems their life, and precious is their blood in his sight.
"15 Long may he live; may gold of Sheba be given to him! May prayer be made for him continually, and blessings invoked for him all the day! 16 May there be abundance of grain in the land; on the tops of the mountains may it wave; may its fruit be like Lebanon; and may people blossom in the cities like the grass of the field! 17 May his name endure forever, his fame continue as long as the sun! May people be blessed in him, all nations call him blessed!"
2 Samuel 7:12: "When your days are fulfilled and you lie down with your fathers, I will raise up your offspring after you, who shall come from your body, and I will establish his kingdom."
Acts 10:38: "How God anointed Jesus of Nazareth with the Holy Spirit and with power. He went about doing good and healing all who were oppressed by the devil, for God was with him."
Psalm 2: "1 Why do the nations rage and the peoples plot in vain? 2 The kings of the earth set themselves, and the rulers take counsel together, against the LORD and against his Anointed, saying, 3 'Let us burst their bonds apart and cast away their cords from us.'
"4 He who sits in the heavens laughs; the LORD holds them in derision. 5 Then he will speak to them in his wrath, and terrify them in his fury, saying, 6 'As for me, I have set my King on Zion, my holy hill.'
"7 I will tell of the decree: The LORD said to me, 'You are my Son; today I have begotten you. 8 Ask of me, and I will make the nations your heritage, and the ends of the earth your possession. 9 You shall break them with a rod of iron and dash them in pieces like a potter's vessel.'
"10 Now therefore, O kings, be wise; be warned, O rules of the earth. 11 Serve the LORD with fear, and rejoice with trembling. 12 Kiss the Son, lest he be angry, and you perish in the way, for his wrath is quickly kindled. Blessed are all who take refuge in him."
+++
The text is public domain:
Hail to the Lord's anointed,
Great David's greater Son!
Hail, in the time appointed,
His reign on earth begun!
He comes to break oppression,
To set the captive free,
To take away transgression
And rule in equity.
He comes with rescue speedy
To those who suffer wrong,
To help the poor and needy
And bid the weak be strong;
To give them songs for sighing,
Their darkness turn to light,
Whose souls, condemned and dying,
Were precious in His sight.
He shall come down like showers
Upon the fruitful earth;
Love, joy, and hope, like flowers,
Spring in His path to birth.
Before Him on the mountains
Shall peace, the herald, go;
And righteousness in fountains
From hill to valley flow.
Kings shall fall down before Him
And gold and incense bring;
All nations shall adore Him,
His praise all people sing.
To Him shall prayer unceasing
And daily vows ascend;
His kingdom still increasing,
A kingdom without end.
O'er ev'ry foe victorious,
He on His throne shall rest,
From age to age more glorious,
All blessing and all-blest.
The tide of time shall never
His covenant remove;
His name shall stand forever -
That name to us is Love.
+++
Psalm 72 is the main source for the hymn text; at least part of each verse comes from it.
2 Samuel 7:12 appears in the lines "Hail, in the time appointed, / His reign on earth begun!" Acts 10:38 (specifically "doing good and healing all who were oppressed by the devil") is referred to at the end of the first verse and throughout the second.
Psalm 2 seems to appear in the fourth verse. The imperative "Serve the LORD with fear, and rejoice with trembling" is a future indicative in the hymn: "Kings shall fall down before Him / And gold and incense bring; / All nations shall adore Him, / His praise all people sing."
Acts 10:38 and Psalm 2 are also related to the titular line. Both contain the word "anointed" (one as a verb; one as a substantive noun).
While they seem to be taken from Psalm 72, I found a few phrases that also bear resemblance to some verses in Isaiah. "He comes to break oppression, / To set the captive free" is similar to Psalm 72:4, but also to Isaiah 61:1: "The Spirit of the Lord GOD is upon me, because the LORD has anointed me to bring good news to the poor; he has sent me to bind up the brokenhearted, to proclaim liberty to the captives, and the opening of the prison to those who are bound" (quoted by Jesus in Luke 4:18). Similarly "Before Him on the mountains / Shall peace, the herald, go" seems to come from Psalm 72:7, but is actually closer to Isaiah 52:7: "How beautiful upon the mountains are the feet of him who brings good news, who publishes peace, who brings good news of happiness, who publishes salvation, who says to Zion, 'Your God reigns.'"