Psalm 118 has no title and names no author. It opens with a liturgy: Israel, the house of Aaron, and those who fear Yahweh each say that his loving kindness endures forever. The same words close the psalm, wrapping the story in thanks.
The singer recounts deliverance. Out of distress, he called on Yah, and Yah answered him with freedom. Yahweh is on my side. I will not be afraid. What can man do to me? (In the New Testament, Hebrews 13:6 echoes this confidence.) He says that it is better to take refuge in Yahweh than to put confidence in man or in princes. Surrounded like bees by hostile nations, he was pushed hard, but Yahweh helped him. Yah is my strength and song.
Then comes a procession to the gates of righteousness and the great reversal: The stone which the builders rejected has become the cornerstone. This is Yahweh's doing. It is marvelous in our eyes. In the New Testament, Jesus applies this to himself (Matthew 21:42), and Peter says it again in Acts 4:11. In the New Testament, the crowd's shout at the triumphal entry comes from verse 26, Blessed is he who comes in Yahweh's name (Matthew 21:9). This is the day that Yahweh has made, and the right response is to rejoice and be glad in it.