Kevin-Prince Boateng came off the bench and scored a hat-trick in the space of 14 minutes, then Mario Yepes nodded in a late winner.
Allegri says it was "an important victory" as Milan showed immense character to fight back from 3-0 down in Lecce.
"We got a bit chaotic on the first goal, then the penalty and an unlucky third made life very difficult for us," said the Coach of their 4-3 thriller.
"When looking at the footage at normal speed, it did seem like a penalty, but the replays show there was no contact. Still, referees can get things wrong, as that is football.
"The fact remains we were too stretched out and couldn't do anything in the first half, partly because Lecce worked harder and constantly doubled up on us.
"We scored straight after the restart and rode the wings of enthusiasm to put the game back on track."