With Sunday's game deadlocked in the 84th minute, Messi curled home a dead-ball effort to earn a victory for the league leaders at the Camp Nou.
It was Messi's 21st career direct free-kick goal in La Liga, giving the Argentine the most of any player since Opta began collecting data in 2003-04.
21 - Lionel Messi has scored 21 direct free-kick goals in La Liga, more than any other player since at least 2003/04 (Cristiano Ronaldo, 20). Magic. pic.twitter.com/5INzUggstM— OptaJose (@OptaJose) January 28, 2018
Messi and Real Madrid star Ronaldo went into the mach deadlocked at 20, but the late winner against Alaves saw the Argentine put his nose in front.
Sunday's match marked another milestone for the 30-year-old, who made his 200th career Liga appearance at the Camp Nou.
Messi has notched a remarkable 211 goals and 74 assists in those 200 appearances.
Barcelona's win restored their 11-point advantage over Atletico Madrid at the top of La Liga.