Captain Messi gave Barca an early lead with a first-time finish after an exchange of passes with Arthur.
The Czech champions were deservedly level when Jan Boril poked home Lukas Masopust’s pass from 16 yards.
But Messi’s free-kick found Luis Suarez at the back post – and his cross-shot hit went in off Peter Olayinka.
Barcelona, who are top of La Liga, have now won six consecutive games in all competitions.
The result keeps Ernesto Valverde’s side top of Group F on seven points from three games, three points above Inter Milan and Borussia Dortmund.
Those two sides met at the San Siro in the group’s other game, with Inter winning 2-0. Lautaro Martinez scored and had a penalty saved before Antonio Candreva’s late clinching goal.
Barca were fortunate to go three points clear at the top – with Slavia deserving more from the game.
The Prague side had more shots – and efforts on target – than Barcelona, most notably a 60-second spell when Marc-Andre ter Stegen got down low to deny Lukas Masopust and then tipped Olayinka’s curling effort over the bar.
Barca were hanging on at the end, with Tomas Soucek and Olayinka having headers saved in injury time.
Slavia were the 33rd side Messi has scored against in the Champions League – a joint record with Cristiano Ronaldo and Raul.
While he has scored in 15 seasons in a row, the Argentine is still one short of Manchester United legend Ryan Giggs’ record of scoring in 16 different Champions League seasons.
The captain could have scored more but was denied by keeper Ondrej Kolar before shooting wide from close range.