Bilbao advanced with a superb shot from Iker Muniain against Marc-Andre ter Stegen.
Newcomer Ferran Torres equalized for the away team with a shot from the edge of the penalty area, scoring his first goal with the Catalan team.
And Iñago Martinez restored Bilbao’s lead four minutes before the end, but Barcelona forced their hosts to go into extra time after Pedri equalized in stoppage time.
Munayen decided Bilbao’s victory with a penalty awarded by the referee after consulting the video assistant referee, for a handball against Jordi Alba.
Bilbao joined Real Madrid, Real Sociedad, Valencia, Real Betis, Rayo Vallecano, Mallorca and Cadiz in the quarter-finals. The lottery is held on Friday.
Barcelona’s disastrous season dealt another blow, as the team had previously been eliminated from the European Champions League, and Ansu Fati and Pedri were injured during the loss against Bilbao.
Barcelona won the title last season after beating Bilbao 4-0.
.