Atletico Madrid's 3-0 win over Las Palmas earlier on Sunday placed a modicum of pressure on Ernesto Valverde's runaway leaders and it seemed to weigh upon them in a ragged first-half showing.
Philippe Coutinho made his full debut, but it was a more unheralded January signing, Alaves' Celta Vigo loanee John Guidetti, who threatened the upset with a fortuitous 23rd-minute opener.
Abelardo Fernandez's side remain two points above the drop zone and were left to rue missed chances by the time Luis Suarez netted for the eighth top-flight match in succession with 18 minutes to play.
Typically, it fell to Messi to apply the coup de grace as he curled a delightful free-kick home in the 84th minute to spark raucous celebrations.
Barcelona remain undefeated and 11 points clear on their apparent procession to LaLiga glory.
Coutinho was lively in the opening stages but looked on as Barca's old guard fashioned an opening in the 15th minute – Messi dropping deep and exchanging slick passes with Andres Iniesta and Suarez before forcing a clearance behind.
Alaves sprung forward from the corner and Marc-Andre ter Stegen was out sharply to deny Ibai Gomez. It was a warning Barca did not heed.
Fernando Pacheco saved low down from Suarez a few moments before Alaves streamed into a vacant Barcelona half on the counter-attack.
Guidetti bore down on Ter Stegen and enjoyed a touch of fortune as he lost his footing and kicked the ball against his other boot, the result leaving the Germany goalkeeper with no chance.
Ter Stegen arched his back to brilliantly keep out a header from Ruben Sobrino, who then ran out of steam having dribbled from halfway into the Barca box to get a shot away.
Coutinho almost found a response when his 32nd-minute effort was deflected wide, while Messi saw an angled free-kick pushed over before Pacheco tipped his next dead-ball attempt against the post to preserve Alaves' unlikely advantage at the interval.
Seven minutes into the second half, Valverde opted to replace his full-backs, with Jordi Alba and Sergio Roberto on in place of the largely ineffective Lucas Digne and Nelson Semedo.
Their introduction added another dimension to Barca's attacking play, but Messi was crowded out when he looked to convert Alba's cutback from the byline.
Ibai should have given Valverde's men a mountain to climb after the hour when he broke through on goal, only to cut back on himself and play in full-back Ruben Duarte, whose rasping shot was deflected behind by Gerard Pique.
Paco Alcacer replaced Coutinho in the hosts' final change and Pacheco judged his angles perfectly in the 68th minute, standing up to thwart Suarez after Messi threaded a delightful pass through Duarte's legs.
Paulinho was unable to bundle in when a roaming Pique caused havoc in the Alaves box, but the pressure eventually told.
Iniesta rolled back the years, embarking on a jinking run before sending a searching cross to the back post, where Suarez's volley took a pair of deflections to spin beyond a helpless Pacheco.
Mubarak Wakaso clattered into Alcacer on the edge of the box, leaving a sense of inevitability when Messi stood over the consequent set-piece six minutes from time, though that did not make his decisive strike any less exquisite.
Alaves felt aggrieved when handball claims against Samuel Umtiti were rejected following a late raid into the area, but, for all the visitors' gallant efforts, earlier wasted opportunities meant they only had themselves to blame.
Key Opta facts:
- Barcelona have equaled their longest unbeaten start to a league campaign in their history (W18 D3); under Pep Guardiola in 2009-10 (W17 D4 L0).
- Lionel Messi has scored 21 direct free-kick goals in LaLiga, more than any other player since at least 2003-04 (Cristiano Ronaldo, 20).
- Luis Suarez is the first player to score in eight games in a row in the top five European leagues this season (11 goals).
- The Uruguay striker has registered his longest goalscoring run in league (LaLiga, Premier League and Eredivisie).
- Barcelona have won more points from losing positions than any other side in La Liga this season (12).