Milan slumped to a shock 2-1 defeat to Spezia as Emmanuel Gyasi scored with almost the final kick of a thriller at San Siro.

Title rivals Inter drew 0-0 with Atalanta on Sunday, but Milan could not take advantage the following day as Spezia came from behind in incredible fashion.

Rafael Leao put Milan ahead after Theo Hernandez's penalty miss, but Kevin Agudelo levelled midway through the second half.

Milan were furious when Junior Messias' fine late effort was struck off due to a premature whistle from the referee, with Zlatan Ibrahimovic then hitting the crossbar.

And Gyasi had the final say, slotting home in the 96th minute to sensationally earn Spezia's first league win at San Siro.

Leao was superb throughout and it was no surprise that he was involved when Milan won a 42nd-minute spot-kick – Ivan Provedel having clattered into the Portugal forward, with referee Marco Serra overturning his decision to award Spezia a free-kick after consulting the VAR.

Spezia thought they had survived when Hernandez dragged his penalty wide, but Leao had other ideas and deservedly put Milan ahead in first-half stoppage time when he lobbed Provedel after latching onto a loose ball.

That was the only one of 25 Milan attempts to find the net, though, and Milan were made to pay for their profligacy. Having been on just six second-half minutes, Agudelo stole in to drill home from Daniele Verde's cross.

Serra appeared to apologise to Milan's disbelieving players after blowing up for a foul on Ante Rebic moments before Messias found the top-left corner from the loose ball.

Then, a combination of Provedel and the bar kept Ibrahimovic at bay, and there was another twist in the tail when Viktor Kovalenko squared for Gyasi to seal a famous Spezia win.