Sead Kolasinac's unfortunate own goal in just the third minute sent the South Americans on their way before Messi scored with a fine second-half effort.
Substitute Vedad Ibisevic gave Bosnia hope with an 85th-minute goal, but they were unable to find an equaliser.
Messi, like his team, had been largely poor until the 65th-minute goal as Argentina, one of the tournament favourites, toiled away manfully in the Group F clash.
Alejandro Sabella would have been worried about the opening hour, but his team finished decently after Messi's second World Cup goal and first since 2006.
Starting with a 5-3-2 was perhaps the biggest surprise to Sabella's Argentina line-up.
Napoli forward Gonzalo Higuain was left on the bench, seemingly still yet to recover fully from an ankle injury.
In their first ever World Cup game, Bosnia-Herzegovina had few shocks in their starting XI with Edin Dzeko leading the line in a 4-2-3-1.
But Safet Susic's men made the worst possible start to be behind after two minutes and eight seconds.
Messi's set-piece from the left was headed by Marcos Rojo, hit a stranded Kolasinac and crept past goalkeeper Asmir Begovic for the fastest own goal in World Cup history.
Izet Hajrovic almost had Bosnia level in the 13th minute, but goalkeeper Sergio Romero scrambled away after the midfielder's heavy first touch.
Despite the awful start, Susic's side looked comfortable in defence and were just lacking some polish in the attacking third.
Maxi Rodriguez blazed well over from 30 yards just after the half-hour mark for Argentina, while Javier Mascherano's effort from range forced Begovic into a save moments later.
An off-balance Dzeko tried his luck from outside the area in the 33rd minute, but he curled his left-footed shot over the bar.
A largely dull first half was brought to life four minutes before half-time.
Senad Lulic almost had Bosnia's equaliser from a Miralem Pjanic corner, only for Romero to push the header around his post in the last chance of the half.
But Bosnia remained on the front foot after the interval as Hajrovic struck a free kick straight at Romero from 25 yards in the 50th minute and then shot at him from range.
Sergio Aguero's strike from an angle lacked the power and direction to seriously trouble Begovic after he was teed up by Messi.
Messi had squandered a good free kick chance before he doubled Argentina's lead in the 65th minute in truly emphatic style.
The Barcelona star exchanged passes with Higuain, skipped past a challenge and placed his left-footed shot in off the post from the edge of the area.
Ibisevic pulled a goal back for Susic's side - their first ever in the World Cup - as he poked through Romero's legs after a fine through ball by Lulic, but Argentina held on.