Occasions of prayer and fasting in the Bible:
Praying for health: "David pleaded with God for the child. He fasted and went into his house and spent the nights lying on the ground" (2 Samuel 12:16)
Praying for safety: "There, by the Ahava Canal, I [Ezra] proclaimed a fast, so that we might humble ourselves before our God and ask him for a safe journey for us and our children, with all our possessions" (Ezra 8:21).
As an act of repentance: "When they had assembled at Mizpah, they drew water and poured it out before the LORD. On that day they fasted and there they confessed, "We have sinned against the LORD." And Samuel was leader of Israel at Mizpah" (1 Samuel 7:6).
As a sign of mourning: "They mourned and wept and fasted till evening for Saul and his son Jonathan, and for the army of the LORD and the house of Israel, because they had fallen by the sword" (2 Samuel 1:12).
Before making an important decision: "While they were worshiping the Lord and fasting, the Holy Spirit said, 'Set apart for me Barnabas and Saul for the work to which I have called them.' So after they had fasted and prayed, they placed their hands on them and sent them off….Paul and Barnabas appointed elders for them in each church and, with prayer and fasting, committed them to the Lord, in whom they had put their trust " (Acts 13:2-3; 14:23).
Teachings on prayer and fasting in the Bible:
Fasting is a personal event: "When you fast, do not look somber as the hypocrites do, for they disfigure their faces to show men they are fasting. I tell you the truth, they have received their reward in full. But when you fast, put oil on your head and wash your face, so that it will not be obvious to men that you are fasting, but only to your Father, who is unseen; and your Father, who sees what is done in secret, will reward you" (Matthew 6:16-18).
Fasting can be from things besides food: "The husband should fulfill his marital duty to his wife, and likewise the wife to her husband. The wife's body does not belong to her alone but also to her husband. In the same way, the husband's body does not belong to him alone but also to his wife. Do not deprive each other except by mutual consent and for a time, so that you may devote yourselves to prayer. Then come together again so that Satan will not tempt you because of your lack of self-control" (1 Corinthians 7:3-5).
Jesus did not require fasting as a part of Christianity: "They [Pharisees] said to him, 'John's disciples often fast and pray, and so do the disciples of the Pharisees, but yours go on eating and drinking.' Jesus answered, 'Can you make the guests of the bridegroom fast while he is with them? But the time will come when the bridegroom will be taken from them; in those days they will fast.'"
Fasting is a form of worship: "Then was a widow until she was eighty-four. She never left the temple but worshiped night and day, fasting and praying" (Luke 2:37).