40[For the choir director: A psalm of David.] I waited patiently for the LORD to help me, and he turned to me and heard my cry.2He lifted me out of the pit of despair, out of the mud and the mire. He set my feet on solid ground and steadied me as I walked along.3He has given me a new song to sing, a hymn of praise to our God. Many will see what he has done and be amazed. They will put their trust in the LORD.4Oh, the joys of those who trust the LORD, who have no confidence in the proud or in those who worship idols.5O LORD my God, you have performed many wonders for us. Your plans for us are too numerous to list. You have no equal. If I tried to recite all your wonderful deeds, I would never come to the end of them.6You take no delight in sacrifices or offerings. Now that you have made me listen, I finally understand - you don't require burnt offerings or sin offerings.7Then I said, "Look, I have come. As is written about me in the Scriptures.8I take joy in doing your will, my God, for your instructions are written on my heart."9I have told all your people about your justice. I have not been afraid to speak out, as you, O LORD, well know.10I have not kept the good news of your justice hidden in my heart; I have talked about your faithfulness and saving power. I have told everyone in the great assembly of your unfailing love and faithfulness.11LORD, don't hold back your tender mercies from me. Let your unfailing love and faithfulness always protect me.12For troubles surround me - too many to count! My sins pile up so high I can't see my way out. They outnumber the hairs on my head. I have lost all courage.13Please, LORD, rescue me! Come quickly, LORD, and help me.14May those who try to destroy me be humiliated and put to shame. May those who take delight in my trouble be turned back in disgrace.15Let them be horrified by their shame, for they said, "Aha! We've got him now!"16But may all who search for you be filled with joy and gladness in you. May those who love your salvation repeatedly shout, "The LORD is great!"17As for me, since I am poor and needy, let the Lord keep me in his thoughts. You are my helper and my savior. O my God, do not delay.