Griezmann ended his goal drought of nine matches in all competitions as Barca closed the gap on the Madrid clubs at the top of the table.
Barca took the lead after 12 minutes when Griezmann reacted quickest inside the box and finished into the bottom corner.
Griezmann then turned provider when he set up Messi who curled the ball into the top corner.
Messi scored his second just before half-time with a stunning free-kick. The Barca captain has now scored 10 goals or more in La Liga for the 15th consecutive campaign.
Griezmann grabbed his second of the match after 63 minutes with a half-volley from a tight angle.
"Before I could barely score one goal but right now it looks like things are going pretty well," Griezmann said postmatch.
"This is an important win, we knew we were in a difficult situation and couldn't afford to lose any more games and it's been a very good week for us, winning three games, all away from home, and while playing some very good football," Koeman said after the match.
"We showed that the team is growing in quality and in confidence. I'm very pleased that we scored four goals and we need to keep playing like we did today, when we only needed a few chances to score."