Real Madrid's 2-1 defeat at Valencia earlier in the day would have allowed the Catalans to edge ahead in the title race if they had won.
But coach Luis Enrique started with Lionel Messi, Neymar and Dani Alves on the bench following the festive break.
And they were unable to inspire a fightback as Moyes secured a memorable second win as Sociedad manager.
Messi, Neymar and Alves only returned to training last Friday after an extended break in South America during the league's Christmas shutdown.
Enrique took the gamble of starting without them for a fixture that has proved tricky for Barcelona in the past.
And so it proved again with their winless run at Anoeta now extended to six games.
In Moyes's previous two home La Liga games, former Arsenal striker Carlos Vela had struck in the opening five minutes.
And while there was to be no repeat for Vela, Sociedad were still ahead after just two minutes as Alba headed a cross from Sergio Canales past his own keeper.
For a team which had already beaten Real Madrid and defending champions Atletico Madrid in San Sebastian this season, it was the perfect start.
Sociedad have been difficult to beat under Moyes, with just two losses in their previous seven matches since the former Manchester United and Everton boss took over in November, and they clung tenaciously to their lead.
They were helped by an insipid first-half performance from Barcelona, who rarely threatened an equaliser.
Sociedad went closest to a second goal when Canales turned sharply and tested former Socieded keeper Claudio Bravo at his near post.
Not surprisingly, Enrique sent on Messi at the start of the second half and waited just a further 12 minutes to introduce Neymar to try and spark an improvement.
Barcelona increasingly dominated possession and began to camp around the Sociedad penalty area.
But with a wall of blue and white shirts to pass, they could not turn their pressure into any meaningful chances.
Sociedad defended superbly with goalkeeper Geronimo Rulli making his one real save four minutes from time when dashing out to save at the feet of Luis Suarez as Moyes's side held on to move up to 13th in the table - five points above the drop zone.
Barcelona's next La Liga game is against champions Atletico Madrid next Sunday.
David Moyes's Real Sociedad stopped Barcelona going top of La Liga thanks to an early own goal from Jordi Alba.