Athletic Bilbao held out with nine men to secure a first win over Barcelona in four years and carry a 2-1 lead into the second leg of their Copa del Rey last 16 tie on January 11.
Two goals in three first-half minutes from Aritz Aduriz and Inaki Williams put the hosts in command.
Lionel Messi's fine free-kick halved Barca's arrears after the break.
And the five-time World Player of the Year was inches away from a precious second away goal when he hit the post with the final kick of the game after Raul Garcia and Ander Iturraspe had been sent-off.
"We struggled at the start," admitted Barca boss Luis Enrique.
"They used two counter-attacks to put together two good moves and get ahead.
"In the second-half we concentrated more on what we could control, our play, and I think we did enough to deserve more, even taking into account Athletic's numerical disadvantage."
Enrique started all three of his star strike force of Messi, Luis Suarez and Neymar despite handing them an extended winter break which meant they only returned to training on Monday after two weeks off.
This is the sixth time Barca and Athletic have been paired together in the Cup in nine seasons, including three finals.
Barca have emerged victorious in all five previous occasions, but Athletic looked well on their way to reversing that run with two excellent goals midway through the first-half.
Firstly, Aduriz stooped unmarked to head home Garcia's cross and round off a fine team move on 25 minutes.
No side other than Real Madrid has eliminated Barca from the Cup since 2008 and the holders will remain confident of turning the tie around on home soil on Wednesday.