"And being let go, they went to their own companions and reported all that the chief priests and elders had said to them. So when they heard that, they raised their voice to God with one accord and said: 'Lord, You are God, who made heaven and earth and the sea, and all that is in them, who by the mouth of Your servant David have said: "Why did the nations rage, and the people plot vain things? The kings of the earth took their stand, and the rulers were gathered together against the LORD and against His Christ." For truly against Your holy Servant Jesus, whom You anointed, both Herod and Pontius Pilate, with the Gentiles and the people of Israel, were gathered together to do whatever Your hand and Your purpose determined to be done. Now, Lord, look on their threats, and grant to Your servants that with all boldness they may speak Your word, by stretching out Your hand to heal, and that signs and wonders may be done through the name of Your holy Servant Jesus.' And when they had prayed, the place where they were assembled together was shaken; and they were all filled with the Holy Spirit, and they spoke the word of God with boldness" (Acts 4:23-31).
After being released, Peter and John returned to be with the other apostles and updated them. They then prayed to God "with one accord." In other words, they were united in their thoughts as they spoke to God. They are wisely seeking His guidance and strength in a time of crisis. Their reverence for God is clear as they acknowledge Him as the great Creator, implying He is a Being of supreme authority and power. Interestingly, their prayer then continues by including a quote from David (cf. Psa. 2:1,2). Thus, we have an inspired prayer quoting inspiration of the past! The essence of David's words is a prediction of opposition to God. However, those who attempt to resist God are foolish and their efforts are vain, no matter how strong they number. God has a right to rule over mankind and all the Universe because He is the Creator (cf. Exo. 20:11). The notion that any wicked effort could prosper against Him is laughable!
The particular application of David's prophecy that the apostles have in mind pertains to Jesus and His rejection by "Herod and Pontius Pilate, with the Gentiles and the people of Israel" (Acts 4:27). These fought against God by crucifying Jesus, but their efforts were vain for He did not remain dead! Though it was not their intent, the exercise of their free will in this act of injustice fulfilled the purpose God had predetermined (i.e., the death of His Son as a perfect sacrifice for sin that atonement for the world might become possible).
As their prayer continues in Acts 4:29, the apostles do not pray for deliverance or for their own safety from the persecution they are beginning to experience. Rather, they pray for boldness that they might continue to speak the word of God! Their work of teaching and living God's message was their chief priority, not their own well being. They also ask for God to perform more miracles through the name of His "holy Servant Jesus." It was through miracles by the power of the Spirit that the word of God was revealed and confirmed (cf. Heb. 2:3,4; Mark 16:20). The apostles desire for God's work to prosper and for the influence of the word of God to grow.
God answers their fervent prayer immediately by shaking the place where they were assembled (like an earthquake, perhaps?) and by filling them with the Holy Spirit. I understand this to mean that the Lord strengthened them to continue doing the work He wanted them to do, and they did so "with boldness" (Acts 4:31).