Ayew's half volley on the 81st minute was enough to separate the two teams and it saw the hosts punish Brentford, who went down to ten men after Rico Henry received a straight red card - a decision that was controversial to say the least.
Ayew, more then anyone, would have been relieved to see his effort fly in, especially considering that his spot kick in the 64th minute was kept out by David Raya.
Nevertheless, this victory for Steve Cooper's side is undoubtedly huge, after snatching a play-off spot on the final day of the season, they came out on top against a team that just missed out on an automatic promotion place.
Story of the game
The home side made a bright start to the encounter, but it was Brentford who created the first opportunity inside four minutes, however, Said Benrahma was unable to direct his header on target after being found by a Mathias Jensen cross from the right.
Four minutes later, Ollie Watkins forced Erwin Mulder into a smart stop when his flicked on header inside the area, was parried to safety by the stand in goalkeeper.
Although, just before the midway point in the first period, the Swans created a fantastic chance when Connor Gallagher flicked the ball into the path of Rhian Brewster who was in space, but his shot was straight at Raya.
Then just after the drinks break, Watkins missed a gilt edged opportunity to break the deadlock when he was found free at the back post by Henry, but the potent goalscorer got his header all wrong meaning that the hosts got away with it.
Seven minutes before the break, somehow Swansea did not take the lead themselves when a Ayew header from a Gallagher corner from the left cannoned off the post and the follow up was then met by Brewster, but from point blank range he couldn't force the ball over the line.
On the stroke of half time, Benrahma had a decent chance to put his side ahead, after he went on a brilliant run to find his way into the box, but he was unable to find the finishing touch as his effort sailed over the bar.
Six minutes after the interval, despite Swansea making a good start to the second second period the Bees created yet another good chance as when on the counter attack Benrahma slipped in Mathias Jensen but his shot from a tight angle was dragged well wide of the target.
As the away side were building up the pressure on the Swans, Watkins had another opportunity to claim the first goal of the game, but he could not get a good contact on his header inside the six yard box after being the first to latch on to a brilliant delivery by Bryan Mbuemo.
Although the turning point of the clash came four minutes later, when Brewster was tripped inside the box by Pontus Janssen leading the referee having no alternative but to point to the spot.
However, Ayew, who before this had scored all of his last five penalties, saw his spot kick well kept out by Raya after he guessed the right way.
Then referee Keith Strout made a brave decision on the 66th minute to send off Henry for a late challenge on Connor Roberts, but on reflection it looked to be a harsh decision as the full back looked to win the ball.
The hosts then looked to take advantage of an extra player on the field and they could have had a second penalty when Brewster went down under the challenge of Raya inside the area.
Although the referee viewed this incident as a dive, consequently leading him to book Brewster.
Nevertheless, with only nine minutes remaining Ayew more than made up for his penalty miss when he smashed a half volley into the top right hand corner when a flick by Jay Fulton found the Swans top goalscorer inside the area.
With a man less on the field, for the rest of the game Brentford failed to cause too much threat to their oppositions defence, with their only noteworthy late chance falling again to Watkins, but he was unable to sort out his feet in time when the ball was fired in to him inside the box and Swansea were able to clear the ball to safety.
Still a lot to do for the Swans
Despite tonight marking a brilliant win for Swansea, it is only half of the job done.
They still have a massive task to earn at least a draw at Griffin Park on Wednesday - a place where Brentford have lost only four times at in the league this season.
Furthermore, despite doing it successfully tonight, they will have to keep the Bees deadly front three of Watkins, Benrahma and Mbuemo at bay once again - a trio that combined have netted on 56 occasions while also bagging 20 assists between them this campaign.
Swansea's attacking force a constant threat
Cooper's front two of Ayew and Brewster with Gallagher sitting in behind them always gave Brentford's centre back partnership of Janssen and Ethan Pinnock something to think about throughout the encounter.
Before the sending off of Henry, when Brentford were maintaining the majority of the ball, the Swans looked a dangerous threat on the counter attack as the pace of the two strikers meant that the Bees centre backs were forced to sit in deeper.
Additionally when Brentford were sent down to ten man and consequently Swansea began to take control of the game, the service from midfield went directly into Ayew and Brewster.
The reason for this was with the two strikers combined having now 28 goals to their name through doing this the hosts knew that it would be their best chance of grabbing that all important goal- something that Ayew himself eventually managed to do.