Pioli's side went in front through Ante Rebic just over 10 minutes from time, but a superb 92nd-minute free-kick from Nedim Bajrami looked to have earned the host a point.
However, 105 seconds after Milan had conceded the equaliser, Fode Ballo-Toure turned in Rade Krunic's flick-on to make it 2-1, before Rafael Leao made sure of the three points with a delicate dink over Empoli goalkeeper Guglielmo Vicario.
The Rossoneri remain within striking distance of Serie A leader Napoli, just three points behind, and Pioli spoke after the game of his players' team spirit.
"I'm interested in playing with stubbornness and determination, and today we did it," he told DAZN.
"The team showed that they had mentally prepared the game well in the first half hour, but we had to score, and we didn't succeed.
"I'm happy with the team's performance. It's clear that we have to score a few more goals, and we have conceded something to a team that plays well, so that's okay.
"If we managed to break the deadlock, it would be an even more favourable situation. At some point, it was the 76th minute, and it seemed incredible to me that we were still 0-0."
The win came at a cost, though, as Davide Calabria, Simon Kjaer and Alexis Saelemaekers all went off injured.
And Pioli acknowledged how the absences were affecting his team, adding: "It is clear that the injuries have disunited us a little bit.
"I have a group of players who want to test themselves commendably, so we must also go on with injuries.
"Today we unfortunately had two muscle injuries, one who had been away with the national team and another who was not well."