Cristiano Ronaldo was sent off as Real missed an opportunity to overhaul Barcelona and take second place.
The Portuguese forward saw red after clashing with Ander Iturraspe and appearing to push the defender in the face.
Real had moved ahead in the 65th minute when Ronaldo set up Jese to score from close range on his first La Liga start.
Bilbao equalized through Ibai Gomez after 73 minutes, the substitute finding the net with his first touch, and two minutes later Real was down to 10 men courtesy of Ronaldo's dismissal.
The result ends a run of five consecutive league wins for Carlo Ancelotti's men and leaves them three points behind Atletico, and level with Barcelona after the latter's defeat to Valencia.
Bilbao maintained its undefeated league record at the new San Mames, and has not lost in four league games.
Real Madrid's intentions were clear from the outset and they started at a ferocious pace with Ronaldo and Jese both firing wide within the first three minutes.
However, Bilbao soon settled and should have gone in front in the 18th minute when Ander Herrera's superb throughball found Aritz Aduriz. After escaping the attentions of Pepe, he could only place wide of Diego Lopez's right-hand post.
Another good chance was spurned by the hosts when Iker Muniain failed to control Oscar de Marcos' fine low cross.
Real was subdued but set out to change that straight away in the second half, Luka Modric unleashing a long-range drive that Gorka Iraizoz did well to tip around the post.
The visitors thought they had taken the lead in the 50th minute when Xabi Alonso's lofted pass was volleyed in by Ronaldo, but the scorer had strayed marginally offside.
Bilbao was indebted to Iraizoz again three minutes later as he repelled Karim Benzema's fierce near-post drive, while Muniain unleashed a curling effort at the other end that went just over.
Real hit the front in the 65th minute when Ronaldo's low cross found the sliding Jese, who prodded in.
The lead didn't last long, as Ibai came on with 16 minutes left and almost immediately drilled in a fine 25-yard effort that went in off the post.
Real was then reduced to 10 men when Ronaldo and Iturraspe clashed and the forward was penalized for raising his hands.
It could have been worse for Real, but Diego Lopez made a superb flying save to tip over Ibai's dipping shot.