Messi broke the club record of 232 official goals set by Cesar Rodriguez during the 1940s and 50s when he coolly lobbed home his second of the match in the 67th minute to put Barca back in the lead after Granada had fought back from two down to 2-2.
The three-time FIFA World Player of the Year has now scored an incredible 54 goals in 45 games for the Catalan giants this season.
It was initially thought Rodriguez had scored 235 official goals for the Blaugrana, but Barca announced this morning that the figure had been amended to 232 following a joint study by the club and La Vanguardia newspaper
Barca substitute Cristian Tello then added a fourth before Messi completed his eighth hat-trick of the season in the 86th minute to put his side 5-2 ahead.
There was still time after that for Granada, who had cancelled out early strikes from Xavi and Messi with second-half goals from Diego Mainz and Guilherme Siqueira, to pull another goal back when Siqueira slotted in his second penalty of the night after Dani Alves had been sent off.
However, Barca had already done enough to claim the win that puts further pressure on Madrid, who face a potentially tricky trip to Villarreal tomorrow [Wednesday] night.
Barca, who had started last weekend 10 points adrift of Jose Mourinho's side, had appeared set for another big home win when Xavi and Messi scored in the opening 17 minutes.
Isaac Cuenca's cross to the far post was nodded back by Messi to Xavi near the penalty spot and the Spain international found the back of the net despite not getting a clean connection on his volley.
Messi then saw a good chance saved before the Argentina international equalled Rodriguez's club record with a far-post volley following another Cuenca cross from the right.
Messi missed another opportunity to secure his spot in the history books in the 52nd minute when he scuffed a shot wide as Barca made a sluggish start to the second half.
The focus then quickly switched from whether the three-time FIFA World Player of the Year could break Rodriguez's record to whether Barca could get the three points as Granada stunned their hosts by drawing level.
It was 2-1 in the 55th minute when Mainz got above Gerard Pique to head in Jorge Carlos Martins's free-kick, and then six minutes later it was 2-2 as Siqueira slotted in from the spot.
Alves gave the penalty away with a clumsy challenge on Daniel Benitez in the box and Siqueira sent Victor Valdes the wrong way from 12 yards.
That was a wake-up call for Pep Guardiola's men, and they did not take long to respond with Messi putting them back ahead within six minutes with his milestone goal.
The flag stayed down as Messi latched onto Alves' through-ball and the 24-year-old lobbed the ball over the outcoming Julio Cesar to take his tally to an incredible 54 goals in 45 games for the European champions this season.
Messi was also involved in Barca's fourth goal in the 82nd minute as his thunderous cross-shot was palmed out by Julio Cesar, with Tello latching onto the loose ball to roll his shot into the net.
The night was Messi's though, and so was the match ball in the 88th minute as he completed his hat-trick with a typically clinical finish, picking up Alves' through-ball, rounding Julio Cesar and slamming his shot into the roof of the net past two covering defenders.
Granada pulled a third goal back in the 89th minute after winning another penalty, with Alves harshly being handed his marching orders after Benitez's attempted cross deflected off his thigh onto his hand.
Siqueira cheekily dinked the resulting penalty home, with Valdes again going the wrong way, but it was Barca celebrating at the end on a record-breaking night for Messi and one that proves the title race is still alive.