Marc-Andre ter Stegen saved a penalty in the 90th minute after goals from Gerard Pique and Ousmane Dembele overcame Pablo Sarabia’s ninth-minute strike to hand Barca their first trophy of the season.
Messi, who was appointed Barca’s new captain earlier this week, moved clear of Andres Iniesta as the club’s most decorated player; Iniesta won 32 before moving to Japanese side Vissel Kobe this summer.
“I don’t know what Messi must be feeling right now,” Barcelona coach Ernesto Valverde said after the match. “If someone’s going to reach that sort of milestone, that many trophies with one club, it’s him.
“It’s incredible. It’s fitting that he has the [club] record. We hope it doesn’t end here and he keeps on winning more.”
The Argentina international’s first trophy was the 2004-05 La Liga title, won while Messi was still a teenager.
He has since won the Spanish title another eight times, while he has also helped the Catalans to Champions League success on four occasions: in 2006, 2009, 2011 and 2015.
There have also been six Spanish Cups, seven Spanish Super Cups, three European Super Cups and three Club World Cups.
Messi’s most successful year with Barca came in 2009, when the club won all six of the trophies available to them, something never done before or since by any other side.
After Lionel Messi and Iniesta come Gerard Pique and Sergio Busquets, who both won their 28th trophy for Barcelona in the Super Cup victory over Sevilla.
Xavi Hernandez, the club’s record appearance-maker, won 25 trophies before leaving for Qatar in 2015.