The Argentine superstar went into the match at Camp Nou level with Athletic Bilbao legend Telmo Zarra's record total of 335 goals for a single Spanish club, but scored in each half to set the new benchmark.
And in scoring twice, Messi also overtook Real Madrid icon Alfredo Di Stefano's tally of 227 La Liga strikes, with his second of the game on 68 minutes drawing him level with another Real hero, Raul.
The 26-year-old - who was withdrawn 16 minutes from time with Tuesday's UEFA Champions League clash with Manchester City in mind - is now only 23 goals behind Zarra's all-time record of 251 in the Spanish top flight.
Messi doubled Barca's lead in the 36th minute with a brilliant, delicate chip after Adriano had put them ahead early on.
Alexis Sanchez and Pedro put the champions 4-0 up before Messi and Neymar - who came off the bench to make his return to Liga action after an ankle injury - completed the scoring in the final 20 minutes, taking them back above Atletico Madrid on goal difference at the top of the table.
It took the hosts just two minutes to take the lead, and they did so in style as Adriano cut in from the left, beat his marker before lashing a powerful drive into the bottom corner.
Barca were rampant and should have got a second 14 minutes in. Messi brought down Cesc Fabregas' lofted pass in the area but could only strike the post after producing a clever swivel.
Rayo were unable to capitalise on the hosts’ uncharacteristically wasteful finishing to that point as they struggled to gain a foothold in the game, and Pedro was the next to hit the woodwork as he came in from the left and fired a low effort on to Ruben’s right-hand post.
Gerardo Martino's side eventually added a deserved second nine minutes before the break, though, as Messi raced on to Fabregas’ throughball and produced a delightful lob over Ruben from the edge of the area.
Barcelona got their third eight minutes after the break as Messi showed good vision to play in Sanchez and the Chilean confidently slotted home his 15th Liga goal of the season.
Number four arrived just three minutes later as a fast, free-flowing passing move ended with Fabregas squaring to Pedro near the penalty spot, and the Spain international tapped into an empty goal.
It was then a case of how many Barca would score, and Messi added the fifth when he collected Sanchez's cutback and steered into the bottom-left corner from the edge of the area, but they still were not finished.
Neymar duly wrapped things up in the 89th minute with a wonderful shot into Ruben's top-right corner from 25 yards to round off their final preparations for the Etihad Stadium in sublime style.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.