The Argentina forward, 33, moved one game clear of former midfielder Xavi’s total as Barca closed the gap on leaders Atletico Madrid to four points.
Antoine Griezmann opened the scoring, Sergino Dest scored twice and Ousmane Dembele also found the net.
Messi has now scored 23 league goals so far this season.
At 5-0 down, Ander Barrenetxea did manage to find a consolation goal for Sociedad with arguably the strike of the night, but it was far too late for Imanol Alguacil’s side to stage a fightback at the Anoeta Stadium.
Messi did not disappoint on his history-making night, showing the same energy and enthusiasm he has done throughout his career for the Catalan club.
His first major act was to turn provider for American Dest to score his first goal for Barcelona. The threaded through-ball also took Messi’s assist tally up to eight for the 2020-21 season.
After testing Sociedad goalkeeper Alex Remiro twice in the first half, Messi finally grabbed a well-deserved reward during the second half by poking home Barca’s fourth.
The icing on the cake for Messi came on 89 minutes when the Argentine’s good link-up play with left-back Jordi Alba resulted in a second goal on his special night.
As much as the three points were a welcome birthday gift for boss Ronald Koeman, Barca still trail league leaders Atletico Madrid in the race to become champions.
Earlier on Sunday, Diego Simeone’s men beat Alaves 1-0, thanks to Luis Suarez’s 500th career goal and a late Jan Oblak penalty save.