Aberdeen's unbeaten Scottish Premiership record ended in Paisley as Richard Taylor's towering header earned St Mirren the three points.
It is a first league loss in 21 games for Jimmy Thelin's side, who stay second but are now three points behind Celtic after they won at Hearts.
Rangers also move a point closer, and are now eight points back in third.
St Mirren, too, had been on an unbeaten run - three games before the international break - and raced out of the blocks against their high-flying opponents.
Toyosi Olusanya got in behind the Aberdeen defence from a long punt forward by goalkeeper Ellery Balcombe and kept his cool to slide low past Dimitar Mitov.
The home side were briefly reduced to 10 men when referee John Beaton sent off Alex Gogic for a heavy sliding tackle on Shayden Morris, but after VAR advised Beaton to review the incident, he downgraded it to a yellow card.
Aberdeen manager Jimmy Thelin showed his dissatisfaction with a double change at half-time, bringing on Duk and Kevin Nisbet, and it sparked his side into life.
Duk posed problems down the left, and his cross eventually dropped to Jamie McGrath, who swept home to level the scores.
However, St Mirren stood firm, weathered the storm and slowly turned the tide.
Conor McMenamin had a shot well saved by Mitov, Olusanya fired just wide, but on 83 minutes, Taylor found the back of the net from Mark O'Hara's corner.
Duk hit a post with an audacious backheel soon after, but Aberdeen could not find a second equaliser.