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.
The history man adds to his records
The king of the Nou Camp will become a free agent this summer when his contract expires, but his statistics for the famous club may never be beaten.
Thanks to his double against Sociedad, Messi has extended his tally as Barca’s record goalscorer to 663 goals in all competitions.
When it comes to La Liga’s all-time top scorer, he is out in front with 467 goals. That’s 156 more than closest rival Cristiano Ronaldo’s 311 for Real Madrid.
He has also chalked up at least 20 goals in La Liga in 13 consecutive seasons, the highest record in the competition.
Less than three months into 2021, Messi has already scored 15 goals in the 12 games he has played. And with another El Clasico on the horizon following the international break, the playmaker will be looking to top up his tally of 26 goals in all competitions against rivals Real Madrid – the most any player has scored in the fixture.