The Argentinian star grabbed the winner four minutes from time with a brilliant curling free kick.
Kiev had taken a shock lead after just two minutes. Artem Milevskiy headed the home side in front as he latched onto a free-kick from Andriy Shevchenko.
But Pep Guardiola’s side battled back, and Xavi equalised on 33 minutes, converted an Eric Abidal cross after a flowing Barca move.
The win means the Catalans top Group F, a group in which any of the four sides could have qualified before last night’s games.
Jose Mourinho’s Inter Milan took second place in the group after they saw off Rubin Kazan.
Goals in either half by Samuel Eto’o and Mario Balotelli fired Inter to the knockout phase.
The Nerazzurri had posed little threat before Eto’o broke the deadlock just after the half-hour. Balotelli then all but ended the contest with a superb strike.
Kiev finished bottom with Rubin Kazan claiming the Europa League place.
In Group G, Rangers’ Champions League campaign ended with a whimper rather than a bang as they slumped to defeat against Sevilla.
The Ibrox side had hoped to claim at least one victory in the tournament this season but a Frederic Kanoute penalty early on proved to be the difference between the two teams.
In fact, Rangers would have felt fortunate to leave Spain with such a narrow defeat on a night when the hosts dominated .
Elsewhere Stuttgart eased through to the knockout stages as they saw off Unirea Urziceni 3-1.
Goals in the first 11 minutes from Ciprian Marica and Christian Trasch and Pavel Pogrebniak saw the Germans 3-0 up at half-time. Antonio Samedo grabbed Unirea’s consolation.
In Arsenal’s Group H, Standard Liege goalkeeper Sinan Bolat scored five minutes into injury time to ensure a UEFA Cup place for his side after a 1-1 draw with AZ Alkmaar. Jeremain Lens gave AZ the lead but a goal five minutes into injury time Bolat grabbed to equaliser to secure third in the group for Liege.
Lyon finished their Group E campaign in style with a 4-0 drubbing of Debrecen.
Bafetimbi Gomis opened the scoring in the 25th minute and Michel Bastos added a second before the break as Lyon seized total control.
Further strikes in the second period through the excellent Miralem Pjanic and left-back Aly Cissokho saw Lyon comfortable winners but they must settle for second in the group as Fiorentina have a superior goal difference.