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 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.
Milan dominated much of the game but spurned a host of chances.
In the 44 minute, Rafael Leao escaped behind the Spezia half 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 pints 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 afer contracting Covid-19.