Cacau, fresh from his four-goal haul against Cologne at the weekend, gave Stuttgart a deserved half-time lead but Ibrahimovic struck just after the interval to put Barca in the box seat heading into the second leg at the Nou Camp.
Barca coach Pep Guardiola remarked afterwards: "We were not very good when we lost possession. [Sergio] Busquets and Xavi were a little lost. We improved after the break and the goal from Ibrahimovic calmed us but we always tried.
"We cannot take anything for granted. We must fight because these teams are tough. If you're not right, the consequences can be costly. This is the last 16 of the Champions League.
"The result is good but how it was achieved was not. We clearly need to improve if we are to win titles."