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.
Inago Martinez put Bilbao back in front four minutes before the end, but Barcelona He forced his host into overtime after Pedri equalized in injury time.
Munayen decided Bilbaos victory with a penalty awarded by the referee after consulting the video assistant referee, for a handball against Jordi Alba.
Bilbao joined real Madrid And Real Sociedad, Valencia, Real Betis, Rayo Vallecano, Mallorca and Cadiz in the quarter-finals. The lottery is held on Friday.
Barcelonas 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.