The 23-year-old Colombian's team Ineos announced he was dropping out ahead of the key 17th stage.
Bernal came into the Tour with a back injury and missing key allies and two of his team then suffered injuries before Bernal himself suffered a meltdown on a tough ascent on Sunday that effectively ended his 2020 campaign as he fell eight minutes behind the pace.
"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 in a statement from Ineos.
The stage on Wednesday takes the peloton over the highest peak in this year's race in a ride that resembles the one where the man from the Andes sealed his breakthrough win last year.
Slovenian rider Primoz Roglic leads the Tour, riding for the Jumbo team that has eclipsed Ineos this year. Amother Slovenian, Tadej Pogacar, is second and a clutch of riders are still in with a chance of a shot at the podium.
Bernal was a distant 16th in the standings and his team have failed to find their form on the race.
"We have taken this decision with Egan's best interests at heart," said Ineos team principal Dave Brailsford.
"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."
Bernal's withdrawal almost certainly ends a sequence of five straight Tour de France victories for Ineos and its previous incarnation, Team Sky.
Giro d'Italia champion Richard Carapaz, Ineos's best-placed rider, is 14th in the standings, 17 minutes behind Roglic.
Ineos has won seven of the last eight Tour de Frances, interrupted only by Vincenzo Nibali's victory for Astana in 2014.
Ineos decided to drop four-time winner Chris Froome, who is recovering from a serious crash last year, and 2018 champion Geraint Thomas for this year's race, leaving the team with less clout and Bernal exposed.
Questions have also been raised about Ineos's training and usually meticulous preparations as Bernal and co-captain Carapaz have been run ragged.
Another key factor in the unexpected slump could be the death of their charismatic sports director Nicholas Portal in March.
Brailsford and Portal helped Bradley Wiggins to his Grande Boucle win in 2012, Chris Froome to wins in 2013, 2015, 2016 and 2017, Geraint Thomas in 2018 and Bernal in 2019.
But there were ominous signs for Bernal two weeks before the Tour when he was forced out of the Criterium du Dauphine with a back problem.
On Sunday, he struggled badly on the last of three massive mountain climbs on Stage 15, the defining moment of the race so far.
"I lost three years of my life on that climb, I gave it everything. But I just couldn't keep up," Bernal said after the stage.
Despite that meltdown Bernal seemed to have rediscovered his smile during Tuesday's stage and there was little sign he was about to pull out.
"I have the greatest respect for this race and I'm already looking forward to coming back here in the years ahead," he said.