Lionel Messi scored two gorgeous goals befitting the occasion as he moved level with Xavi as Barcelona's all-time record appearance-maker in Monday's 4-1 win over Huesca, moving the Blaugrana up to second in LaLiga.

The Barca captain was playing his 767th match for the club across all competitions and played a starring role as Ronald Koeman's men closed the gap on leaders Atletico Madrid to four points, though there were a few scares along the way.

Messi's sumptuous effort got the ball rolling, as Barcelona's talisman became the first player in LaLiga history to net 20 goals in 13 successive campaigns, and Antoine Griezmann scored an arguably even better effort soon after for his 150th top-flight strike.

A farcical penalty allowed Huesca to pull one back through Rafa Mir, who also inexplicably wasted a remarkable opportunity in the wake of Oscar Mingueza making it 3-1, and Messi finished them off towards the end with another fine goal.

The game was just 13 minutes old when Messi made his mark, effortlessly bending a 20-yard effort around Alvaro Fernandez and into the top-left corner via the crossbar.

Jordi Alba almost made it 2-0 just past the half-hour when his shot from a tight angle was kept out by the frame of the goal, but two minutes later Griezmann picked out the same corner as Messi but from about 10 yards further out – his first league goal since the end of January.

Huesca got themselves a lifeline in bizarre circumstances just before the break, Mir converting a penalty after Marc-Andre ter Stegen was deemed to have fouled him when essentially brushing the striker's shin with his hand, the ball having flashed past both of them.

Barca restored the two-goal lead early in the second period, Mingueza getting his head to a Messi cross to open his account for the senior side.

Huesca should have reduced the deficit again a few moments later, though, as Mir somehow nudged the ball over the goal from under the crossbar with his chest after latching on to Dani Escriche's header across goal.

Messi capped off a wonderful individual display with his second goal in the 90th minute, receiving Francisco Trincao's pass and elegantly picking out the bottom-left corner from just outside the box.

What does it mean? '¡Hay Liga!'

The top three each have 11 matches left and there only six points between first and third – on top of that, Atletico have won just two of their previous five league games, hardly the form of a team certain it can hold off pressure from challengers. Madrid are unbeaten in eight and have won six of those, meaning Zinedine Zidane's men will be confident of chipping away at the gap.

But surely Barca, undefeated since early December in LaLiga, hold the trump card: an in-form Messi. This brace took him to 10 goals in his past nine matches across all competitions. After everything that has happened between Messi and Barca, could he actually guide them to the title? What looked a pipedream in December now appears a real possibility.

Messi playing with a smile

A momentous day for reasons already explained, Messi also collected his first LaLiga Player of the Month award of the season just before kick-off. Throughout he actually looked happy to be there, his celebrations full of joy and his attacking play bursting with positivity. His three key passes were not matched by anyone else on the pitch, while he had a hand in three of Barca's four goals and touched the ball 124 times – the most he has recorded in a league game this term.

Messi has outperformed his xG by 6.6 since the turn of the year

Rafa's wasted chance was no Mir miss

Granted, Mir did score the penalty that he won – remarkably. But it is difficult to look past his astonishing second-half miss at 3-1. A goal then, when he cleared the crossbar from almost directly underneath it, would have really tested Barca's mettle and resolve, particularly given Huesca actually looked a credible threat when they went forward. That was one of five shots he had, but only two were on target.

Key Opta facts
- Barcelona have gone 17 games without losing in LaLiga (W14 D3), the best current unbeaten streak of any team in Europe's top five leagues.
- Mingueza's goal means Barcelona have seen 17 of their players score at least once this season, becoming in the team with more different scorers in the top leagues. Atalanta, Borussia Dortmund and Manchester City all have 16.
- No other player has scored more goals from outside the box in Europe's elite divisions than Messi (seven) this season.
- Griezmann scored his 150th LaLiga goal. He has 16 for Barcelona, 40 for Real Sociedad and 94 for Atletico Madrid.

What's next?

Barca will be expecting more of a test at Real Sociedad on Sunday, while Huesca continue their fight for survival at home to Osasuna a day earlier.