The topic of du'a and its relationship with destiny (qadr) is a very important one, and one around which much confusion exists. Many people ask: "If everything has already been destined to occur, then of what use is du'a, as, if Allah has written what I want, I will get it without making du'a, and if it is not written for me, then I will never get it no matter how much du'a I make?"
The response to this question lies in understanding the outcome of anything is dependant on the performance of the efforts that are necessary to procure it. In other words, it has already been decreed, for example, that a seed will give fruit if planted, but this will not occur unless the farmer takes the appropriate efforts in irrigating the crop, maintaining it, protecting the seedling as it grows, and ensuring as much as he can that the factors are amenable for the plant to give fruit.
So even though a person believes in the Divine Decree, he must at the same time strive all he can to ensure that the desired goal occurs. So du'a is the means that one uses to achieve the desired goal that one has, and this means in no way contradicts the destiny that has been written for that person.
This stance is clarified by the Prophet's hadith reported by Thawban, that he said:"Nothing increases one's life-span except good deeds, and nothing repels Divine Decree except du'a. And very, a person may be deprived for sustenance due to a sin that he does!"[Narrated by Ibn Majah #90 and confirmed authentic by Shaykh al-Albani in as-Sahihah #154]
In other words, the performance of good deeds is a cause of increasing one's life span, so if a person puts in the necessary effort, the results will be achieved, and this is also destined. So both the means to achieve a goal, and the fulfilment of the goal itself, are already decreed.
If someone were to ask: "How can du'a repel Divine Decree?" we would respond, "The fact that you may be ill has already been decreed by Allah for you, as has the fact that you will ask Allah to cure you of this illness (i.e. both the illness and your asking to cure the illness has been decreed). In a similar manner, a person may be deprived of his sustenance that was decreed for him since Allah's eternal knowledge encompassed the fact that this person would perform a sinful deed that would cause deprivation of his sustenance. All of this, then, is from the decree of Allah, all Glory and Praise be to Him."