According to Exodus and related Old Testament books, the Israelites wandered in the wilderness for 40 years. The period followed their departure from Egypt and their failure to enter Canaan after the scouting mission described in Numbers.
The wilderness journey is a central episode in the Torah. The Israelites traveled through the Sinai region, received laws and covenant instructions, and relied on divine provision. The biblical account links the 40-year period to the generation that had left Egypt: that generation would not generally enter the promised land.
The number is also associated with the transition from Moses’ leadership to Joshua’s. Deuteronomy states that Moses was 120 years old at his death, and Joshua then led the people across the Jordan into Canaan.
Readers sometimes confuse the 40 years of wilderness wandering with the 40 days Moses spent on Mount Sinai or the 40 days the spies explored Canaan. These are separate periods.