Bernal had been struggling since the weekend stage in the Jura mountains featuring Col du Grand Colombier, where he dropped more than seven minutes on the main contenders and slipped out of contention.
After Monday's rest day, the 2019 champion suffered again on Tuesday night's (AEST) stage to Villard-de- Lans.
Hampered by back pain and subsequently knee concerns, the 23-year-old rider lost more time during the first Alpine stage, although he had indicated afterwards he hoped to ride to continue out of respect for the race.
But on the morning of Wednesday's queen stage to the Col de la Loze above Meribel, Ineos Grenadiers announced Bernal was out of the race.
"This is obviously not how I wanted my Tour de France to end, but I agree that it is the right decision for me in the circumstances," Bernal said.
"I have the greatest respect for this race and I'm already looking forward to coming back in the years ahead."
Bernal was in 16th place overall, 19 minutes and fours seconds behind race leader Primož Roglič.
The decision comes five days short of Paris.
"We have taken this decision with Egan's best interests at heart," Ineos Grenadiers team manager Dave Brailsford said.
"Egan is a true champion who loves to race, but he is also a young rider, with many Tours ahead of him and at this point, on balance, we feel it is wiser for him to stop racing."
Wednesday night's (AEST) Stage 17, arguably the toughest, features the Col de La Madeleine and the Col de La Loze, the Tour's highest point this year at 2,304 metres.
The traffic-free pass between the ski resorts of Meribel and Courchevel was opened to cyclists this year after a forest track was paved by local authorities.
The last six kilometres of the climb are particularly difficult, with very steep sections and sharp turns.
Bernal, who in 2019 became the youngest rider to win the Tour de France in 110 years, had pulled out of the Criterium du Dauphine with back pains last month.
He will now focus on his recovery from the Tour, and reset his goals for the rest of the season, his team said.
The 2020 Tour de France continues with the brutal 170km stage from Grenoble to Méribel (Col de La Loze) - the highest point of this year's Tour is on the menu. Stage 17 begins via SBS On Demand and the SBS ŠKODA Tour Tracker from 8:05pm (AEST) on Wednesday, with the television broadcast set to start at 9:35pm on SBS.