Among the things that the Prophet (peace be upon him) said to Mu`âdh when he dispatched him to govern over Yemen was: “And be wary of the supplication of the oppressed, for between it and Allah there is no barrier.” [Sahîh al-Bukhârî (1496, 2448) and Sahîh Muslim (19)]
This is understood to mean that the supplication of the oppressed against his oppressor is answered.
It is clear from the context that this is a strong warning against oppressing others. The Prophet (peace be upon him) was warning Mu`âdh to be wary of wronging the people under his authority.
It should not be regarded as an encouragement to invoke supplications against other people every time they do something wrong to you. It is better to pray for their forgiveness and to bear their misdeeds with patience.
At the same time, supplication is the refuge of the truly oppressed and downtrodden. When oppression and weakness strips a person of all practical hope and leaves that person with no one to give support against those who oppress him, that person raises his or her hands to the sky and sets forth his or her complaint before the Lord, the Almighty. Allah strengthens that oppressed person and brings relief, and He lets His wrath fall upon those who oppress.
We see that Noah (peace be upon him) supplicated against his people when they oppressed him, spurned him, and rejected his call.
Also, when Moses (peace be upon him) beseeched Allah in supplication against Pharaoh after he had transgressed, oppressed, and tyrannized Moses's people, Allah answered his supplication. The oppressor’s lot is disgrace in this world and a painful chastisement in the Hereafter.
`Umar said, when he appointed Hunayy to manage the affairs of an area: “Restrain your hands from wronging the Muslims and be wary of the supplication of the oppressed, for indeed the supplication of the oppressed is answered.” [Sahîh al-Bukhârî (3059)]
What we must do is take heed of these warnings and refrain from wronging others.
And Allah knows best.