Emmanuel Gyasi coolly finished a 96th-minute counter-attack to give Spezia their first Serie A victory away to AC Milan, 2-1, on Monday night.
Milan gave up a 1-0 lead as they missed a chance to overtake neighbours Inter at the top of Serie A, while third-place Napoli closed to within two points with a 2-0 win in Bologna.
In the late game, Fiorentina crushed dispirited Genoa 6-0 to jump sixth.
Milan dominated much of the game but spurned a host of chances.
In the 44th minute, Rafael Leao escaped behind the Spezia defence but was flattened by goalie Ivan Provedel kicking wildly at the bouncing ball.
Theo Hernandez fired the penalty wide.
A minute later Leao escaped again and this time reached the ball first and lobbed Provedel to give Milan the lead.
Spezia hit back when Kevin Agudelo, finding a huge hole in the home defence, tapped in a low Daniele Verde cross at the near post after 64 minutes.
As the game entered five minutes of added time, Junior Messias put the ball in the net for Milan, but the referee had already whistled for a foul rather than allow the home team the advantage.
Milan coach Stefano Pioli blamed that decision for what happened next.
"We lost our lucidity after having suffered an injustice, it's a shame," Pioli told Italian broadcaster DAZN.
"The responsibility is ours but it must be shared tonight with the referee. It's all the more strange that he didn't whistle for half-fouls during the whole game and now he whistles when the ball is on our player's foot."
Milan applied frenzied pressure and Provedel made three saves from Zlatan Ibrahimovic.
The first was from a close-range shot, the second from a curling free kick and the third, and best, to claw away a looping header dropping just under the bar.
Spezia sprung one last counter-attack. Victor Kovalenko rolled the ball across the penalty area to Gyasi, who, with the game on the line, carefully controlled then coolly placed the ball inside the far post.
"Anyone can have a bad night," said Pioli. "We will try to react, the team has always known how to do it."
Milan host Juventus on Sunday.
It was Spezia's third straight away victory and lifted them to 14th in the table, six points clear of the relegation places.
In Bologna, Mexican Hirving Lozano scored from close range in the 20th and 47th minutes.
Striker Victor Osimhen came on for the last 20 minutes wearing a protective mask, a little less than two months after suffering facial fractures.
Osimhen had travelled to Nigeria to join the national squad for the Africa Cup of Nations but returned to Italy after contracting Covid-19.
In Florence, rising star Dusan Vlahovic squandered an 11th-minute penalty for the home team with a lazy Panenka that Salvatore Sirigu, reaching up, pawed away.
It hardly mattered, as the home team tore apart Genoa, who have won once in the league all season and on Saturday fired Andriy Shevchenko after just two months as coach.
Four minutes later, Sirigu dived at Vlahovic's feet for a brave save but the ball ran to Alvaro Odriozola who scored to start the rout.
Cristiano Biraghi struck with two long-range free kicks. Giacomo Bonaventura scored from close range. Vlahovic hit the target with another cute lob. Diminutive Lucas Torreira ended the scoring with a header.
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ