Simone Inzaghi's side trail AC Milan by two points and could hand their local rivals the Scudetto if they don't beat relegation-threatened Cagliari on Sunday.
Juve meanwhile have only Champions League qualification to show for an up-and-down season, but they chose to say nothing about the penalty decision which denied them a trophy.
"Inter are fighting for the league title and we're behind them. We need to close that gap with hard work and looking to sort out the team," said Allegri.
Nicolo Barella gave Inter the lead in the sixth minute with a long-range effort which would soon be forgotten amid the controversy to come.
His thumping strike came after a blistering start from Inter which threatened to blow Juve away, the Italy midfielder collecting after a corner was cleared, cutting in side and unleashing a curling effort which Mattia Perin didn't even bother trying to stop.
However from then on Juve were the better team and should have gone in at the break at least level, if not ahead.
Paulo Dybala was the first to offer signs of life in the 23rd minute when his low shot was comfortably saved.
Moments later the Argentine fed Vlahovic whose powerful, angled drive needed smart reactions from Samir Handanovic to be kept out.
Matthijs de Ligt had a header well saved on he half-hour mark and it looked for all the world that Dybala would bag a deserved leveller when the subsequent corner fell kindly to him, but he sliced his first-time strike wide.
Juve soon turned the match on its head though, with Sandro levelling the scores five minutes after the break when his shot slipped through Handanovic's hands as Alvaro Morata tried to deflect the ball.
The Juve fans were jumping and their end of the ground exploded with joy seconds later, Vlahovic ending a four-match dry spell in front of goal after being sent flying through on goal by Dybala.
The Serbia forward sent Danilo D'Ambrosio packing and although his first effort was kept out, the 22-year-old made no mistake on the rebound.
Juve looked to have the game under control until referee Valeri handed Inter an ill-deserved lifeline.
Calhanoglu rifled home from the spot and an already fired-up Juve team then lost control when De Ligt was ruled after a VAR check to have chopped down Stefan de Vrij.
Perisic stepped up to smashed in the penalty in the 99th minute and once the Croat's decisive second flew in from distance three minutes later there was chaos, with Allegri sent off and players and officials tussling on the sidelines.
However Juve couldn't turn that anger into a fightback and Inter took the honours to set up a potential league and cup double with the Serie A season heading to its climax.