The Swiss lost 6-3 7-6 (7-4) 6-0 to the 14th seeded Pole, who reached his first Grand Slam semi-final.
It is the first time 20-time major champion Federer has lost a set to love at the All England Club.
Hurkacz will play seventh seed Matteo Berrettini for a place in Sunday’s final.
The Italian defeated Canada’s Felix Auger-Aliassime 6-3 5-7 7-5 6-3 to reach his first Wimbledon semi-final.
“It’s super special for me,” said Hurkacz, only the second Polish man to reach the semi-finals at a Grand Slam.
“Playing here and the special things [Federer] has done here, it’s a dream come true.”
Hurkacz, who was six when Federer won his first title at SW19, is the first player to win a set to love against the Swiss since Rafael Nadal in the 2008 French Open final.
Federer, at 39 years and 337 days, had been bidding to become the oldest man to reach the Wimbledon semi-finals in the Open era.
But defeat marked his first straight-set loss at Wimbledon in 19 years and left pundits and fans wondering whether this could turn out to be his final appearance at the grass-court Grand Slam.
Federer himself said he “does not know” if he will play at Wimbledon again.
Off-colour Federer falls short in bid to match record
Federer had two knee surgeries in 2020 and this was only his fifth event in 17 months, but had made no secret of the fact Wimbledon was his target this year as he looks to equal Martina Navratilova’s record of nine singles titles here.
With Novak Djokovic – into the semi-finals after defeating Marton Fucsovics – breathing down his and Rafael Nadal’s necks in the race for the most Grand Slams, this could have been his last chance to pull clear of his old foes on his best surface.
There had been concerns over his form coming into the tournament after a last-16 defeat by Auger-Aliassime at the Halle Open last month left him despondent, and he avoided an upset in the opening round of Wimbledon when Adrian Mannarino was forced to retire after slipping and injuring his knee.
Although comfortable wins over Richard Gasquet, Cameron Norrie and Lorenzo Sonego followed, he looked far from his best against Hurkacz, 15 years his junior, in gusty conditions on Centre Court.
Having made 31 unforced errors compared to Hurkacz’s 12 in defeat, Federer quickly packed up his belongings and traipsed off court, his head hanging before a final wave to all corners of the applauding arena.
Hurkacz shines against boyhood hero
An impressive Hurkacz, who won the Miami Open in April before going off the boil in the following tournaments, forced but squandered three break points before finally breaking Federer’s serve in the sixth game of the opening set.
He went on to take first blood in just 28 minutes against his childhood idol, Federer hitting 10 unforced errors in the first set with his play full of mis-hits.
The Swiss won the first three games of the second set but needed to dig deep to save three break points as Hurkacz, who has won just nine Tour-level matches on grass, continued to apply the pressure.
Federer still looked sluggish despite his promising start to the set and Hurkacz broke back in the seventh game, the rest then remaining on serve to set up a tie-break in which a slip on what looked a simple volley at the net at 4-2 down proved costly for Federer.
And then everything unravelled in the third set, Federer only once holding break point as Hurkacz wrapped up the win in one hour 51 minutes on his first match point.
Hurkacz, who has been compared to British former world number one Andy Murray, said: “I was trying always to believe myself during the match and just trust my game and stay as aggressive as I could.
“That what I was trying to focus on throughout the match.”
Federer’s final farewell? – Reaction
Boris Becker, three-time Wimbledon champion on BBC TV: “I noticed the mis-hits, awkward looking points from Roger and obviously the last set of course, 6-0.
“He would never ever say if there was a niggle, but I don’t know if we will ever see the great man again here.
“There were some awkward looking points from Roger in the tie-break – something we’ve never seen from him on Centre Court.
“We can only wonder what happened and only he can answer that. As they say, time doesn’t stand still for no man or woman.”
Andrew Castle, BBC Sport tennis commentator on BBC One: “A magnificent demolition of a great champion, Hurkacz disposes of Federer in straights and it is his moment.
“We just don’t know if this is a final farewell for Federer and he certainly isn’t about to hang about and discuss it.”