After Ayew’s first-half opener, Boro appeared to have salvaged a point when Sam Morsy’s deflected effort beat Swans goalkeeper Freddie Woodman in stoppage-time.
Yet there was still time for a late twist when George Saville was adjudged to have fouled Jake Bidwell in the box and Ayew converted from 12 yards.
Boro boss Neil Warnock was furious with the officials after the match after Marc Bola saw a goal ruled at 1-0 out when team-mate Yannick Bolasie was penalised for a foul on Jay Fulton.
Warnock was also unhappy that Swansea’s Ryan Manning wasn’t punished for a foul on Anfernee Dijksteel in the first half.
The result leaves Boro ninth in the Championship table, seven points off sixth-place Barnsley in the final play-off position.
Here’s how the visitors fared at the Liberty Stadium: