Luis Suarez assisted three goals and scored the other as Barcelona went three points clear of Real Madrid at the top of La Liga.
French International, Antoine Griezmann scored the opener and then Arturo Vidal blasted in a second, before Pere Pons' header for Alaves. But Messi smashed home an excellent 25-yard strike and then Suarez scored a penalty following a handball.
Barcelona end 2019 with 24 wins and four draws at the Nou Camp - their first unbeaten year at home since 2011.
Argentina forward Messi also had a goal disallowed before reaching his half-century of goals for club and country this year. He has reached that landmark in nine of the past 10 years. He is set to finish as Europe's top goalscorer in 2019 - with 34 goals in 32 La Liga games leaving him five clear of anyone else yet to play.
Barcelona will remain on top of La Liga over Christmas, unless Real Madrid beat Athletic Bilbao by six goals later on Sunday.