A-League All-Stars 2 Juventus 3: Pepe spares Juve's blushes with late winner
The winger, who has seen his Juve career blighted by injuries in recent seasons, produced a low finish in the 94th minute to rescue the Serie A champions after a scare in Sydney.
Having already seen his side beaten by fifth-tier Lucento and held by Cesena during pre-season, head coach Allegri looked like adding a defeat to that list until Juve scored twice in the closing stages.
Marcelo Carrusca opened the scoring for the A-League's representative side early in the first half with a well-placed finish, and the hosts held their lead until the 60th minute when Fernando Llorente headed an equaliser.
The visitors looked more likely to go on and win the game, only for Tomi Juric to put the hosts back ahead with an instinctive strike.
However, the All-Stars were denied a memorable victory as late goals from Paul Pogba, in the 88th minute, and Pepe turned things around.
A lively start from the hosts saw former Juve star Alessandro Del Piero have the first sight of goal after eight minutes; his free-kick struck the wall, but a minute later the All-Stars were ahead through Carrusca.
Matt Smith brought the ball confidently out of defence to begin a flowing move that ended with Carrusca cutting inside Angelo Ogbonna, before firing low into the bottom corner of Gianluigi Buffon's net.
Juve were struggling to cope with their opponents and nearly fell further behind on the half-hour as Besart Berisha forced Buffon into a smart save, the experienced goalkeeper pushing a curling shot wide.
The visitors gradually found their stride as Andrea Pirlo began to dictate proceedings, and a neat move between Allegri's front two almost brought an equaliser.
Carlos Tevez and Fernando Llorente exchanged passes on the edge of the penalty area but the Argentine's low shot struck a post before bouncing out for a goal kick.
Juve eventually levelled as Patrice Evra made good ground down the left and, after being found by Pirlo, delivered a pinpoint cross to find Llorente, who headed beyond Eugene Galekovic.
A host of changes gave the All-Stars a boost and with 13 minutes remaining they claimed what appeared set to be a winning goal, as Juric cut in from the left edge of the area and lashed the ball into the back of the net.
With time running out and Juve staring defeat in the face, it was Pogba who initially came to the rescue with a sumptuous volley over Mark Birighitti to level the match, but the drama was not over.
The All-Stars failed to clear a late Juve corner and Pepe latched onto the loose ball inside the penalty area to fire into the bottom corner and seal the victory.