Philippe Coutinho took only 92 seconds to give Barca the lead at Wembley on Wednesday, with Rakitic's unstoppable 25-yarder doubling the Catalan side's first-half advantage.
Harry Kane's 10th Champions League goal gave Spurs hope and, although Messi soon put Barca 3-1 up, Erik Lamela struck to set up a grandstand finish.
Ernesto Valverde's men had failed to win their last three games and looked nervy in the closing stages, but Messi capitalised on poor defending in the last minute to ensure his team join Inter on maximum points after two games in Group B.
Hugo Lloris was playing for the first time since August after recovering from a thigh injury but the Tottenham captain's mistake contributed to Barca's second-minute opener.
Messi produced a gorgeous ball to send Jordi Alba scampering clear down the left channel and, with Lloris having raced out and left his goal unmarked, the left-back squared for Coutinho to tuck away his first Barca goal in the Champions League.
The visitors, returning to Wembley for the first time since lifting the Champions League there in 2011, extended their lead in stunning fashion soon after Kane had Spurs' first shot.
Coutinho performed a minor miracle to keep the ball in play on the byline with Rakitic launching himself into a sensational 20-yard volley that clipped the post on its way into Lloris' net.
Marc-Andre ter Stegen made a great save to keep out a Son Heung-min cross that sharply deflected off Gerard Pique, who was making his 100th Champions League appearance, and Messi hit the post twice in five minutes after the restart before Kane gave Spurs a lifeline.
A long throw from Lloris set up a counter, with Lamela feeding Kane to turn Nelson Semedo and bend a fine finish into Ter Stegen's bottom-left corner.
Messi would not miss again, though, sending Alba clear down the left with a trademark curling pass and timing his run into the box perfectly to slot a first-time finish past Lloris to restore Barca's two-goal lead four minutes later.
Lamela's deflected strike wrongfooted Ter Stegen and ensured a fantastic finale but, with Spurs committing men forward, Alba seized on a loose pass to set up Messi to sweep home his second.
What does it mean: Crisis over for Valverde
Valverde said after Barca lost at Leganes last month that every defeat is an "earthquake" for the club, with talk of crisis intensifying after he rested Messi and saw his side held by Athletic Bilbao at the weekend. Spurs put up a better fight after the interval, but Barcelona's second win in eight away Champions League games is a positive sign the LaLiga giants are getting back on track.
Arthur lives up to Xavi and Iniesta comparisons
Being dubbed a cross between Xavi and Andres Iniesta must be a huge weight on Arthur's shoulders, but the Brazilian midfielder is living up to that lofty billing. Arthur plays like he knows he belongs on this stage. He is just 22 and it is frightening to think how good the former Gremio man could become.
Another rare Lloris error costs Spurs
The return of World Cup winner Lloris should have given Spurs a boost, especially as Mauricio Pochettino was without Dele Alli, Jan Vertonghen and Christian Eriksen, among others. But Lloris made a calamitous misjudgement in only the second minute to give Barca a lead they were never likely to give up. Previously reliable, Lloris errors are now far too regular.
Key Opta stats:
92 - Philippe Coutinho's goal after 92 seconds is Barcelona's earliest Champions League goal since Mark van Bommel in November 2005 v Panathinaikos (36 seconds). Rapid. pic.twitter.com/4gN5gFiLYE— OptaJoe (@OptaJoe) October 3, 2018
- Barcelona have won nine of their last 11 Champions League matches against English clubs (D1 L1), with this their first win in England since February 2016 against Arsenal (2-0).
- Lionel Messi has scored more goals (22) and provided more assists (6) against English clubs in the Champions League than against sides from any other nation
- Philippe Coutinho was involved in as many goals in his opening 28 minutes against Spurs for Barcelona (1 goal, 1 assist) as he was in his 715 minutes for Liverpool against them (2 goals).
- Barcelona’s Gerard Piqué made his 100th Champions League appearance in this match, becoming the 10th Spaniard to reach this landmark.
- Tottenham midfielder Erik Lamela's strike was the 8000th scored in Champions League history.
Spurs host Cardiff City in the Premier League on Saturday, while Barca are at Valencia in LaLiga the following day. Matchday three of the Champions League sees a blockbuster between Group B leaders Barca and Inter at Camp Nou, with Spurs travelling to PSV.