The Ghanaian's 90th-minute effort proved the decisive factor in the matchday 34 away fixture at Bet365 Stadium.
The three points consolidate the promotion play-off spot of fourth-placed Swansea, who have two games in hand and sit 11 points below league leaders Norwich City.
Nick Powell put Stoke in the lead in Wednesday's game, pouncing on a loose ball to strike past Swansea goalkeeper Freddie Woodman in the 6th minute.
The visitors fought back to draw level in the 19th minute through Connor Roberts who beat his marker to steer the ball into the net after connecting to Ryan Manning's cross.
With the game headed for a draw, Swansea earned a late opportunity to claim all three points when referee David Webb pointed to the spot after substitute Jack Clarke tripped Kyle Naughton.
Ayew bravely stepped up and coolly drove the ball into the net from 12 yards in the sixth minute of injury time to put his side in the driving seat.
The Black Stars captain took to Twitter to celebrate their victory.
Big win today ???? we keep going ?? ???????? YJB???? pic.twitter.com/Lu6FSDrt1H— Andr