Karim Benzema struck a second half brace after Cristiano Ronaldo had given Real the lead to beat Sevilla as the Madrid side took their record-breaking haul of league goals for the season to 112.
Victory against Athletic Bilbao on Wednesday will guarantee a first title since 2008 for Jose Mourinho's team.
"It was an important win and the team deserves to be champions as the players have shown their mentality and character," said Real assistant coach Aitor Karanka.
Referring to their Champions League exit at the hands of Bayern Munich, he added: "The players went into the game tired and down but they responded well, even though winning the league will not cure anything.
"We will go out looking to win games even when we are the champions, if that happens, as we only have one plan. It will be fantastic to win the league and it is the most important objective at the moment."
Barcelona, in their first match since Pep Guardiola announced he would quit at the end of the season, produced a sensational attacking display to help ease a little of the pain suffered by their midweek Champions League exit to Chelsea.
Lionel Messiput Barca ahead and then an own goal from 'Rober' Correa, who turned in an Alexis Sanchez shot, and a Seydou Keita strike gave them a 3-0 lead at the interval.
Pedro Rodriguez got a double in the second half and Thiago Alcantara was also on target before, a minute from the end, Messi got his second.
It means that Messi is now joint top scorer in the league with Ronaldo on 43 goals.
"We prepared for this game as we would for any other and I was very pleased with the way that the team played. We worked hard in what was a tough match against a side looking for points to stay up," said Guardiola.
"This is a very young squad with an average age of 23-24. I know the players very well and I am sure this team will continue at the top."
It was an unfamiliar looking Barcelona side with Xavi Hernandez and Gerard Pique out injured while Guardiola chose to give reserve keeper Jose Pinto and youngster Martin Montoya a run out.
Although they lacked fluidity in the middle of the pitch to begin with they maintained their deadly attacking threat and Messi put them in front with 15 minutes gone after he was unselfishly played in by Pedro.
Messi then found Alexis who rounded the keeper and his shot from a tight angle went in off Rober after 26 minutes, while Keita finished a fine move to give Barca a three-goal lead before the break.
With a minute gone of the second half Pedro added the fourth, knocking in a rebound after Messi's shot had hit the crossbar, and then 13 minutes from the end Thiago headed home but there was still time for further goals from Pedro and Messi.
Follow us @SprtNationalUAE