Pickford earlier escaped a red card after conceding a penalty which he saved, but was beaten three times inside the last 25 minutes as the Magpies roared back. Marco Silva's team looked to be coasting after Dominic Calvert-Lewin and Richarlison gave them a 2-0 lead either side of Matt Ritchie's missed spot kick, but Salomon Rondon's strike set up a grandstand finish in which Perez struck twice inside three minutes to help Newcastle claim a fifth successive home win.
In the 18th minute, Bernard's fine reverse pass put Lucas Digne into space and his cross was expertly headed home by Calvert-Lewin at the near post. The Magpies should have been level in the 31st when, after Pickford spilled Ritchie's cross, he hauled down Rondon in his pursuit of the loose ball and referee Lee Mason pointed to the spot, but did not reach for his pocket.
However, the England 'keeper redeemed himself by saving Ritchie's penalty, and the home side's misery took a turn for the worse within seconds when Richarlison tapped home Bernard's cross from close range with Isaac Hayden lying prone further up the field.
The Magpies were back in it with 25 minutes remaining. Perez headed the ball down to Rondon and, after collecting the return pass, crossed for the Venezuela international to volley past Pickford. The game became wide open with nine minutes remaining when Pickford could only parry Miguel Almiron's blistering strike and Perez steered the rebound home, and St. James' Park erupted when the Spaniard stabbed home from close range three minutes later to win it.
More AP soccer: https://apnews.com/apf-Soccer and https://twitter.com/AP_Sports