The game at the Amsterdam ArenA looked set to be another frustrating chapter in a disappointing season for Frank de Boer's team.
But Anwar El Ghazi headed an 82nd-minute winner to move his team 11 points behind runaway leaders PSV Eindhoven.
Utrecht were Sunday's big winners with a thumping 6-2 triumph over AZ.
The UEFA Europa League hopefuls were blown away during the opening stages as Willem Janssen and Mark Diemers netted before a Sebastien Haller penalty made it 3-0 to Utrecht in the 17th minute.
Haller was on target from the spot once more after Aron Johannsson reduced the deficit and a Kristoffer Peterson own goal in the 83rd minute made it 5-1.
Utrecht's Gevero Markiet was the next man to put through his own net, but the hosts had the final word as Edouard Duplan struck a minute from time.
Feyenoord moved up to third place at AZ’s expense thanks to a 3-0 victory over NAC Breda.
Fred Rutten's team took a 10th-minute lead through Lex Immers, whose goal was the first to be confirmed by the HawkEye goalline technology system in the Eredivisie.
Mitchell Te Vrede hit a second-half brace for the hosts to seal second-bottom NAC's fate.
Elsewhere, Albert Rusnak and Tiaronn Chery scored to give Groningen a 2-0 win over basement boys Dordrecht.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.