According to the Gospels, Jesus fasted in the wilderness for forty days before being tempted.
Matthew 4, Mark 1, and Luke 4 place Jesus in the wilderness immediately after his baptism and before the beginning of his public ministry. Matthew and Luke specifically state that he fasted for forty days and forty nights, after which he was hungry and faced temptations from the devil. Mark gives a shorter account but also places the wilderness episode at the same transition point.
The number forty has important biblical associations. Moses spends forty days on Mount Sinai, and Israel’s wilderness journey is described as lasting forty years. The Gospel story therefore connects Jesus with earlier figures and themes while presenting his own period of testing. The account is not a claim that Jesus remained without food for forty years or that all four Gospels narrate the episode with identical detail. Forty days is the standard Gospel figure and is also reflected in the Christian season of Lent.