Aritz Aduriz scored the only goal of the game midway through the first-half with a thumping header from Mikel Rico’s cross.
The visitors improved after the break, but couldn’t find a way past Gorka Iraizoz as Athletic recorded their first victory over the European champions in five years.
Madrid’s third defeat in 11 league games means that Barcelona can move one point clear at the top of the table with victory over Rayo Vallecano on Sunday.
“I think the problem we are having at the moment is quite clear,” said Madrid boss Carlo Ancelotti.
“It is not a defensive problem, it is an attacking problem. We are not finding a way through like we did in the games before. We’ve only scored one goal, from a penalty, in two games.
“That is the problem we have to fix. We lack efficiency up front.”
Athletic came into the game on a high having qualified for the Copa del Rey final in midweek, where they will meet Barcelona for the third time in seven years.
And the hosts went in front on 26 minutes when a lovely team move ended with Aduriz powering home a wonderful header from Mikel Rico’s floated cross.
“To win against Real Madrid without suffering is impossible,” said Aduriz.
“We are very proud of how hard we worked. The three points will prove a huge boost. The fans have enjoyed it a lot and they deserved that after the poor performances at San Mames earlier in the season.”
Madrid didn’t even manage a shot on target despite enjoying most of the ball in the first-half.
However, they upped the tempo at the start of the second period and only an amazing last-ditch challenge from Mikel Balenziaga denied Karim Benzema a goal from Cristiano Ronaldo’s low cross.
Gorka Iraizoz then had to turn a dangerous cross from Bale out of Ronaldo’s reach before diving to his right to save a low effort from Isco.
Iraizoz was quick off his line once more to deny Benzema from a narrow angle as the pressure from the visitors built.
Yet, they could have found themselves two behind 15 minutes from time when another prodigious leap and header from Aduriz came back off the outside of the post.
Moments later it was Madrid that were left cursing their luck when a stunning Bale effort from fully 45 yards came off the post with Iraizoz beaten.
And despite Ancelotti throwing on Jese Rodriguez and Javier Hernandez in the final stages, Madrid couldn’t create another clear chance as Athletic held on for a famous win.
Earlier, Sevilla kept their hopes of a top four finish alive with a thrilling 4-3 win away at relegation threatened Deportivo la Coruna.
While in other matches, Granada picked up three valuable points but remain in the relegation zone, following a 1-0 home win over rivals Malaga and finally Elche edged Almeria by the same scoreline.