The win has handed Swansea City first-leg advantage in the semi-finals of the English championship-play-offs.
The Swans will take a 1-0 lead into Wednesday's second leg at Griffin Park after Ayew lashed home eight minutes from the end to give the hosts an advantage they will feel they deserve after controlling the second half.
READ MORE: I told Muntari in 2011 that Jordan Henderson will be a great player in future- Gyan
Ayew ran towards the home dugout to celebrate his 18th goal of the season, which came just 16 minutes after he had seen a penalty saved.
Brentford were the better side in the first period, when Ollie Watkins and Said Benrahma both missed good opportunities to put them in control.
But the hosts came into the contest after the break, with Brentford's cause not helped when Rico Henry was dismissed for a lunging challenge on Connor Roberts on 65 minutes.
Swansea, who only sealed a top-six spot in the dying minutes of the regular season, continued their surge into promotion contention as Brentford suffered a third successive defeat.