The Wanderers were on track to pull off the upset of the season when Kwame Yeboah’s 39th-minute fluke goal and Roly Bonevacia’s second-half strike gave them a 2-0 lead in Perth on Sunday.
But in a crazy finish to the match, six goals were scored in the space of 19 minutes as Glory snatched all three points.
Glory skipper Diego Castro headed home in the 70th minute to make it 2-1, but the Wanderers’ two-goal lead was restored when Manyiel Riel Majok scored in the 77th minute.
Defender Ivan Franjic gave Perth a sniff when he scored his first Glory goal in the 79th minute after Alex Grant’s header cannoned off the crossbar.
And Glory were amazingly back on level terms when Andy Keogh scored from close range in the 82nd minute following a neat cross from Franjic.
The frenetic finish continued when Glory were awarded a penalty after Wanderers defender Brendan Hamill held Keogh in the box.
Juande stepped up to the spot and scored to give Glory a 4-3 lead in the 86th minute.
The result means Glory maintain their six-point lead over title rivals Melbourne Victory and Sydney FC at the top of the table.
The eighth-placed Wanderers have now lost four straight games, and face an uphill battle to get back into the finals picture.
Glory coach Tony Popovic made five changes to the starting line-up that destroyed Sydney 3-1 on Wednesday.
Perth looked disjointed in the opening half, committing a host of poor errors.
Yeboah caused Glory’s defence all sorts of problems, and his goal in the 39th minute came almost by accident when a corner kick made its way to him at the far post.
Yeboah was caught unaware by the ball, which struck him high on the chest and bounced into the goal.
Glory coach Tony Popovic said it was “a crazy type of game” against his former club.
“We created an amazing opportunity in the first couple of minutes. Then they had a lot of attempts on goal and we defended very poorly today. It’s no real surprise we struggled at times.
“But what’s that they say about character? I’m delighted for everyone involved, the players, the fans, it’s a day I’m sure we’ll all remember.
“If we want to have a chance to win things, these are the games we’ve got to win. We found a win today and we won by dominating.”
The Glory retained their six-point lead at the top of the table.
Sydney FC remain third on goal difference behind Melbourne Victory after edging Adelaide United 2-1 in Sydney on Sunday.
Former Dutch international Siem de Jong was on target for Sydney with an exquisite freekick and defender Jacob Tratt marked his first start with a headed goal from Brandon O’Neill’s corner.
Adelaide’s Craig Goodwin scored from the penalty spot after a foul on George Blackwood and Sydney needed a brilliant reflex save from keeper Andrew Redmayne to deny Ryan Kitto and bank the three points.
Additional reporting Stuff
AT A GLANCE
A-League points after 13 rounds: Perth Glory 32, Melbourne Victory, Sydney FC 26, Melbourne City 23, Wellington Phoenix 22, Adelaide United 19, Newcastle Jets 12, Western Sydney Wanderers 9, Brisbane Roar 7, Central Coast Mariners 2.