Rabeinu Bachyah shares an essential quality of Tefilah, prayer. He quotes a verse in Mishlei:
שוחר טוב יבקש רצון ודורש רעה תבואנו, בוטח בעשרו הוא יפול וכעלה צדיקים יפרחו
“He who diligently strives for good will find favor;
but he who seeks evil, it will come to him.
He who relies on his wealth will fall;
but the righteous will sprout forth like foliage.”
“Shlomo Hamelech espouses the principle of מדה כנגד מדה, [that sooner or later he will be measured by the yardstick he applied to others].”
Rabeinu Bachya ties this idea of Midah Kneged Midah, (a boomerang affect) to prayer.
The word “שוחר” in this verse according to R’ Bachya means Tefillah. He says therefore that one who seeks out good for others through tefillah is fulfilling the Ratzon of Hashem. This becomes a source of Elevation of His Name according to Shlomo Hamelech.
“This is why our sages said in Baba Kama 92 that if someone prays for G’d to grant a particular request to a third party and he himself is in need of having that same request granted by G’d for his own needs, not only will his prayer concerning the third party be granted but his own unspoken prayer will also be granted.”
There are very serious ramifications to this idea according to Rabbienu Bachya; so much so that one is considered a sinner if he fails to daven for another in need. “כל מי שנמנע מלהתפלל נקרא חוטא”.
What about praying for one who is an enemy or who does wicked things?
Dovid Hamelech would fast, and wear sackcloth, and daven for even those who tried to harm him when they would have challenging circumstances, or were facing illnesses. He did not daven for their illness to become more serious even though some of these people were trying to kill him.
Dovid Hamelech tells Hashem, “תפלתי שהתפללתי עליהם תשוב עלי” – may my prayer that I prayed for them return to me” 
Rashi says although some people acted as enemies to him, he would daven to Hashem not to fall prey to them in this way:
כי כל עוד ותפלתי בפי הרי היא בשביל רעותיהם של פועלי און שלא אכשל בהם
“For as long as my prayer is in my mouth,
it is about the evils of the workers of iniquity,
that I should not stumble on them.
It seems to me that what Rashi may be alluding to is that Dovid Hamelech would use his circumstance of those aggressively pursuing him , with destructive acts as his very opportunity to not hold back in prayer. Perhaps he was davening to not stumble by the iniquities that his enemies fell prey to. I wonder if praying in such a way, transformed the evil they were perpetrating by giving it purpose and in this way he created a place for those who fall to return to Hashem by modeling his redirection of the evil to good.
What is so powerful to me about this concept shared by Rabeinu Bachya, is learning firstly that our Neshama actually needs to daven for others. If we “hold back” chas v’shalom we are considered one who has missed the mark, or the Ratzon of Hashem. Torah considers such a person a “chotei” , a sinner. Therefore to fulfill Hashem’s ratzon, we need to daven for others.
The second concept that seems equally powerful to me that this description of how far one needs to go when davening for others as depicted by Dovid Hamelech, I think he is teaching us what it means to fulfill the Mitzvah of “ ואהבת לרעיך כמוך” to love your friend as yourself. I think of the words of Rashi describing Dovid Hamelech “may my prayer that I prayed for them return to me”.
“ I daven for all of us to find ways and strategies to daven for those who need without ever holding back Biezras Hashem.”
“I daven for all of us to use our prayers as our fulfilling of the Mitzvah of ואהבת לרעיך כמוך”
“I daven for all of us to daven with the awareness when we daven to fulfill the Mitzvah of fulfilling Hashem’s Ratzon, by seeking good for others, and therefore emulating Hashem Who is a bestower of good to others.”
“I daven for all of us to develop the sensitivities necessary to understand the needs of others until we can reach a tefillah of Dovid Hamelech, of “may my prayer that I prayed for them return to me”