Seven-time European champions Milan had beaten the Florence-based side only once in their last nine league outings.
But a superb opener from Bacca on four minutes upset the visitors' gameplan and Boateng, who re-signed for the club recently on a six-month loan deal, came off the bench to hit a well-taken second two minutes from the final whistle to wrap up the points.
Fiorentina's sixth defeat of the season proved costly, Paulo Sousa's men left in fourth place at six points behind leaders Napoli, four behind champions Juventus and two behind fellow challengers Inter Milan.
Milan into Cup semi-finals after beating Carpi
Milan moved up two place to sixth to sit 12 points off the pace as they continue their bid for a place in next season's Champions League.
Fiorentina looked impressive as they zipped the ball around in the opening exchanges, although the stakes changed for the visitors after just four minutes.
On a Milan counter, Giacomo Bonaventura held the ball up before releasing Bacca on a run which the Colombian finished by holding off his marker to fire past Ciprian Tatarusanu and into the far bottom corner.
Milan spurned the next chance when Keisuke Honda won possession in midfield and played a one-two with M'Baye Niang, but the Japanese forward's delivery into the box found no takers.
I'm playing on for two years, says 39-year-old Totti
Fiorentina should have levelled before the quarter hour when Josip Ilicic ran through unmarked on to Mario Suarez's ball, but the Slovenian was closed down and after offloading to Federico Bernardeschi the playmaker's snap shot was blocked.
Milan were finding openings on the counter, with Bonaventura and M'Baye Niang showing plenty of pace on the wings.
After Milan 'keeper Gianluigi Donnarumma punched a corner to safety, Niang went on a long run that took him past his marker but his cross for Honda met traffic.
Fiorentina striker Nikola Kalinic was unlucky not to make contact with Marcos Alonso's drive into the box, and the Croatian got his head to an Ilicic corner close to half-time but it glanced wide.
Fiorentina resumed in a more positive fashion after the break, although their promise soon fizzled out.
A Borja Valero free-kick was nodded towards the far top corner by Nenad Tomovic but Donnarumma was alert to the danger.
A long ball from Ilicic sent Kalinic on a promising counter, but with Alessio Romagnoli in hot pursuit the Croatian fired wide of the target.
Moments later, Kalinic headed a meter wide from Valero's cross as Donnarumma swung on to his post.
Milan looked to have soaked up the pressure, but struggled to convert their own half chances, Antonelli firing straight at a thankful Tatarusanu after the ball fell kindly.
Sousa boosted Fiorentina's attack when he replaced midfielder Mario Suarez with Giuseppe Rossi with 25 minutes to play.
But Milan's changes proved decisive.
Boateng came on for Niang and moments after Mario Balotelli replaced Bacca to make his long-awaited return from injury, Boateng beat onrushing Tatarusanu to Juraj Kucka's long ball, rounded the 'keeper and slotted it home from 12 yards.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ