Neil Kilkenny came back to haunt his former side as Adam Taggart scored a 97th-minute winner to lift Perth Glory to a 2-1 win over Melbourne City at nib Stadium on Saturday night.
City's Daniel Arzani opened the scoring in the 44th minute with a beautiful curling strike.
But the game turned on its head in the 66th minute when defender Bart Schenkeveld was red-carded for a second bookable offence.
Schenkeveld, given his first yellow card in the 56th minute after vigorously protesting against a free kick, was sent off 10 minutes later when he fouled Joseph Mills.
Kilkenny starred for Melbourne City last season, but left in acrimonious circumstances last month after a public falling out with coach Warren Joyce.
Glory swooped to sign Kilkenny, who proved his value with an 85th-minute goal from just inside the box.
The drama got even more intense as the match neared its end as Taggart missed two golden chances to put his team ahead.
But he made the most of his third chance after Glory were forced to pull off a goal-line clearance.
Perth played the ball forward and a perfect cross made its way to Taggart, who headed home to send the crowd of 8,029 into raptures.
Just minutes earlier, Joyce was handed a yellow card for venting his frustrations.
The win means Perth are now just four points adrift of sixth spot with six rounds remaining.
City are still in third spot but face a crunch derby against Melbourne Victory on Friday.
Saturday's first half was a dour affair as both sides struggled to create clear-cut opportunities.
The crowd took part in a moving applause tribute in the 10th minute to pay their respects to former Glory midfielder Liam Miller, who died of pancreatic cancer at the age of 36 earlier this month.
Arzani's class was clear to see, but it took until the stroke of half-time for him to be rewarded for his efforts.
The striker rounded Glory defender Dino Djulbic before unleashing a mesmerising right-foot strike into the top corner.
Taggart, sidelined since Jan. 13, was introduced in the 58th minute as Glory searched for an equaliser before providing the killer blow in the dying minutes to keep their faint finals hopes alive.