Read Psalm 118:15-20
Listen to the glad shouts of victory in the tents of God’s people:
“The Lord’s mighty power has done it!
16 His power has brought us victory—
his mighty power in battle!”
17 I will not die; instead, I will live
and proclaim what the Lord has done.
18 He has punished me severely,
but he has not let me die.
19 Open to me the gates of the Temple;
I will go in and give thanks to the Lord!
20 This is the gate of the Lord;
only the righteous can come in.
Verses 10-14 represent harsh struggle. Verses 15-20 celebrate deliverance from that struggle.
The Psalmist gives God the credit for his victory - and for his righteousness. In verse 19 he asks that the gate be opened; in verse 20 the gate keeper answers his call and allows him into the temple.
My righteousness is because of your grace. I'm not very righteous; I need more of your grace.