Messi whipped home a beautiful free-kick six minutes from the end to down resilient Alaves, who are just two points from the drop zone in 17th despite John Guidetti silencing the Camp Nou with a shock breakaway opener in the 23rd minute.
Luis Suarez had broken the away side's tough resistence with a sweet volley from Andres Iniesta's cross 18 minutes from the end, setting the stage for Messi's dramatic and stylish winner.
Barca coach Ernesto Valverdes said he was happy with Coutinho who had started Thursday's Copa del Rey clash with Valencia on the bench before making a second-half appearance.
"Players are not machines who can fit in at once, like a new part," said Valverde.
More From This Section
"He did well, he wanted the ball. This is one more step for him. The other day, he played 25 minutes, this time a little more, he will integrate little by little."
"The first half was not very good but the coach gave us a good talking to at half-time, and we responded well," said Griezmann, whose goal was just his seventh in the league this season but his fourth in league and cup since the turn of the year.
"I feel good, I've started the year well and I hope to continue the goals and assists."
An easy tap-in from Thomas Partey after great work from Yannick Carrasco two minutes from time completed the second- half rout of a desperate Las Palmas, who remain second from bottom and five points from safety.
Sevilla were denied the chance to close within three points of Real Madrid and the Champions league places after Angel Rodriguez scored a controversial equaliser deep in stoppage time to snatch a 1-1 draw for Getafe at the Roman Sanchez Pizjaun stadium.