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.