Messi free-kick kills off Dynamo Kiev
Messi struck four minutes from time as Barca finished top of Group F on 11 points, two ahead of Inter Milan. Kiev finished bottom with Rubin Kazan claiming the Europa League place.
"It was very important for us to finish first in the group and each player gave his best for a victory," Barcelona coach Pep Guardiola told reporters.
"That is the style of our team - to fight up to the end. It was a hard match physically but we do not expect it to be easier in the next rounds," he said.
Dynamo stunned the holders just two minutes after kick off with Artem Milevskiy heading the home side in front as he latched onto a free-kick from Andriy Shevchenko.
Milevskiy's glancing header looked to have been saved by keeper Victor Valdes but the ball squirmed out of his grasp and into the net.
Barca dominated the game from then on even though Dynamo keeper Olexandr Shovkovskiy made a superb save to deny Messi and the Argentine forward saw another shot deflected following a powerful run.
The pressure told in the 33rd minute when they conjured an equaliser, Eric Abidal's cross from the left turned in by Xavi from close range.
The visitors got a scare in the first 10 minutes of the second half when from an Andriy Shevchenko free-kick, Leandro Almeida headed narrowly wide.
Four minutes from time Messi curled in a free-kick that went in off the crossbar to clinch victory.
"We have a big problem losing games in the last minutes," Dynamo coach Valeriy Gazzaev told reporters. "Like in previous games against Inter Milan, we conceded a decisive goal minutes from the final whistle.
"We need to sort this out in the future and learn how to play the full 90 minutes," he said.