Roberto Mancini's side were high on confidence going into the game having won Euro 2020 in July.
They were also on on a 37-game unbeaten streak, a record in international football.
But that streak was snapped as Spain won 2-1.
A brace from Ferran Torres gave the Spaniards a two-goal lead.
Lorenzo Pellegrini halved the deficit for Italy with seven minutes to go but Spain held on to claim the victory.
Cesar Azpilicueta made his 33rd appearance for his country on the evening.
The 32-year-old has been terrific for Chelsea in recent times and he put in another assured display at the San Siro.
The Chelsea captain has been playing for his club in a back five ever since Thomas Tuchel was appointed manager.
That means he has licence to go forward on occasion, knowing that he has cover in defence.
It's not the same with Spain. Luis Enrique plays four-at-the-back, with Azpilicueta on the right-hand side.
HEATED! Does Bruno Fernandes deserve a Ballon d'Or vote? | The Football Terrace
Azpilicueta is used to bombing forward but he can't do it as much for Spain. He realised that during the match in comedic fashion.
The defender did well to go past an Italy forward. He then passed the ball to a teammate and drove up the pitch.
However, just as he was about to make his way into the box, Azpilicueta realised Spain were exposed at the back and he looked devastated that he had to get back into position.
It makes for a hilarious video and you can watch it below:
Brilliant. You can tell by Azpilicueta's body language that he was gutted he had to go back into position.
Azpilicueta has always been a key player for Chelsea but he's been starting to get more recognition by his country in recent times too.
He will most likely be in the starting lineup when they contest the Nations League final against France on Sunday evening.