Home captain Iker Muniain hit the first and last goals of the night, opening the scoring with a delicious strike. Ferran Torres responded against the run of play before half-time with his first goal for Barcelona. Inigo Martínez then scrambled what looked like a late winner, only for Pedri to strike in the third minute of stoppage time.
Muniain restored Athletic's lead with a penalty at the end of the first half of extra time, and this time there was no way back for Barcelona, who lost substitute Ansu Fati to an apparent injury.
Barcelona drubbed Athletic 4-0 in last year's final, with Lionel Messi getting two goals, Antoine Griezmann one and Frenkie de Jong also on target. That made this sweet revenge, and Athletic richly deserved the win.
Muniain gave Athletic a second-minute lead, collecting the loose ball after Nico Williams crossed low from the right. From a deep position beyond the far post, Muniain took two sharp touches to set himself and curled a sumptuous strike over Marc-Andre ter Stegen and into the far corner.
Torres replied from a similar spot and with a comparable finish in the 20th minute, stepping inside Oscar De Marcos and whipping a shot beyond Julen Agirrezabala.
Yet Barcelona were ripe for being picked off at the back and kept allowing chances, Muniain and Nico Williams going close before the break.
The visitor was stronger for the introduction of De Jong and Fati just after the hour, yet they looked doomed when Athletic's second goal arrived in the 86th minute, scrambled in from close range by Martinez after Alex Berenguer's header was only half-blocked by Ter Stegen.
Pedri dramatically made it 2-2 with a thumping strike from 15 yards, but Barca then lost Fati to injury early in extra time, and they conceded a penalty when Nico Williams' cross struck Jordi Alba on the arm from close range. Muniain blasted past Ter Stegen, Barcelona complained to no avail, and it is Athletic who go into Friday's quarter-final draw.