Bayern Munich stumbled to a 1-1 draw at relegation-threatened Nuremberg on Sunday to leave the Bundesliga title race wide open with three games left in the season.
The result leaves Bayern top on 71 points with Borussia Dortmund in second place on 69 after Saturday's 4-2 home loss to Schalke 04 in the Ruhr valley derby.
Third-placed RB Leipzig, who have secured a Champions League spot for next season, are on 64.
Bayern, buoyed by Dortmund's slip-up, knew a win at Nuremberg could potentially see them secure the title as early as next week as it would put them four points ahead of their title rivals.
They were dominant, as expected, and hit the woodwork through David Alaba in the first half.
But it was the home side who struck first with Pereira firing in on the rebound after Bayern keeper Sven Ulreich had blocked a shot three minutes after the break.
The champions were visibly rattled and it took them some time to recover from the setback before retaking the initiative.
After several missed chances, including a James Rodriguez free kick that keeper Christian Mathenia tipped onto the bar, substitute Gnabry finally beat the Nuremberg defence at the far post, beautifully chipping a volley over the keeper in the 74th.
Nuremberg had the chance to win with a penalty awarded in the 89th minute but Tim Leibold hit the post.
Bayern responded by creating a last chance of their own but Kingsley Coman failed to beat Mathenia in a one-on-one in the fifth minute of stoppage time.
"We had a tough German Cup game in midweek and maybe we were not that fresh," Bayern coach Niko Kovac told reporters referring to their 3-2 semifinal win over Werder Bremen on Wednesday. "Nuremberg did it well and fought for every ball.
"They made our life difficult from the first to the last minute. It is frustrating because we could have gone four points clear. Now we must put this behind us as quickly as possible and win all three remaining games."
While Nuremberg fans will praise their 17th-placed team's performance, the draw leaves them five points behind the relegation playoff spot occupied by VfB Stuttgart.