US Open champion Alcaraz suffered his first straight-sets defeat since November last year as Goffin made the most of his second chance as a lucky loser.
Alcaraz, 19, was playing his first ATP tournament since his victory in New York that saw him become the youngest ever world number one.
He played in last month's Davis Cup, winning one of his two singles rubbers as Spain claimed a place in the quarter-finals. Goffin only earned a spot in the main draw after the withdrawal of Danish teenager Holger Rune.
He plays Frenchman Adrian Mannarino in the last 16. "I always believe that I have the level to cause some trouble against those guys," said Goffin, a former top-10 player now ranked 66th. "When you play against the world number one on a big stage, big crowd, the fire inside gives you so much power to play your best tennis because you don't have any choice. "You have to fight and give your best and that was the case today.