Barcelona's Lionel Messi (centre) celebrates a goal with teammates during the Spanish League tie vs Atletico Madrid yesterday. Pic/AFP

Madrid: Lionel Messi struck the winner four minutes from time as Barcelona moved top of La Liga on Sunday with a crucial 2-1 win at Atletico Madrid. All the goals came in the final half hour as Rafinha put Barcelona in front before Diego Godin's header quickly restored parity.

However, so often the thorn in Atletico's side, Messi registered his 27th career goal against Los Rojiblancos to ease the pressure on under fire Barca coach Luis Enrique.

Barcelona now lead Real Madrid and Sevilla by two points. Real, though, have two games in hand on their title rivals, the first of which comes later on Sunday at Villarreal.

Defeat leaves fourth-placed Atletico just one point clear of Real Sociedad in the battle for the final Champions League slot. Following their Champions League thrashing at the hands of Paris Saint-Germain and struggles at home to Leganes last weekend, Luis Enrique switched from the Catalans habitual 4-3-3 to a 3-4-3 with Messi forced into an advanced midfield role.

Barcelona's Argentinian forward Lionel Messi (L) celebrates a goal with Barcelona's Brazilian forward Neymar. Pic/PTI

However, the change in tactics did little to stem Barca's slump in form early on as Atletico dominated the opening half hour. Yannick Carrasco and Godin blasted wildly off target when well placed inside the area early on.

Antoine Griezmann then saw a goalbound effort blocked by French international teammate Samuel Umtiti. Atletico's best effort of the opening half came from long range, though, as Griezmann's driven effort on his weaker right foot forced a brilliant flying save from Marc-Andre ter Stegen.

Barcelona thought they had gone in front against the run of play on the half hour mark when Luis Suarez headed in from close range after a goalmouth scramble. However, the Uruguayan was penalised for a handball after Jan Oblak had parried Messi's initial effort.

Oblak was making his first appearance since December 12, but the Slovenian showed no signs of rustiness to once again prove his credentials as one of the finest 'keepers in the world. Firstly, Oblak produced a sensational stop to tip Messi's dipping free-kick over and then clutched Gerard Pique's header from point-blank range.

Both sides passed up huge chances at the start of the second-half. Firstly, Suarez screwed his shot horribly wide after being played in by Messi. Then at the other end, Ter Stegen made another excellent stop to deny Griezmann from a narrow angle.

The deadlock was eventually broken in scrappy fashion on 63 minutes as Rafinha profited from a loose ball inside the area to fire low into the far corner. However, the lead lasted only seven minutes as Godin rose higher than a host of Barca defenders to flick home Koke's free-kick for the equaliser. Yet, when Barca needed a potential season defining goal, Messi again came up trumps with his 35th in as many games this season.

The five-time World Player of the Year's first effort from Suarez's cut-back was blocked, but he followed up to prod past the helpless Oblak and move Barca top of the table.