
The highly rated Brazilian, 18, burst on the scene by stunning ninth seed Andrey Rublev in Round 1 and looked on track for another upset when he won the first set in Melbourne.
But in a seesawing battle, the 55th-ranked Sonego clawed through 6-7(6/8), 6-3, 6-1, 3-6, 6-3 after 3 hours 37 minutes of high-quality tennis.
The loss ended a 15-match win streak for Fonseca, who was tipped for the top by Carlos Alcaraz and Novak Djokovic this week.
Sonego’s reward in a clash against Hungary’s Fabian Marozsan, who took down 17th seed Frances Tiafoe, also in five sets.
Little separated Fonseca and Sonego in a first set which went to a tiebreaker, where the Brazilian whipped up the crowd and got over the line.
But he was brought back to earth when a series of unforced errors handed Sonego a break for 2-1 in the second set.
The relentless Italian kept pounding away to earn another break for 5-3, with his big serve giving Fonseca little leverage.
The Brazilian’s game began to lose its lustre and he was broken to love, missing a simple net volley, to fall 3-1 behind in the third set.
With his error count rising there seemed to be no way back.
But the teenager was not done and a Sonego double fault handed him a break for 2-0 in the fourth set, holding on to the send the match to a decider.
With the crowd firmly behind him, Fonseca had a break point at 3-3 but failed to covert.
It proved costly, with Sonego breaking in the next game and serving out for the match.
Fonseca last month became the second-youngest champion of the NextGen ATP tournament since current world No 1 Jannik Sinner claimed the title, also aged 18, five years ago.
He then won the ATP Challenger Tour title in Canberra before powering through Melbourne Park qualifying.