While Newcastle end the campaign in 10th place in the standings, Chelsea finish in fifth position, five points adrift of Liverpool who claimed fourth spot.
Mohamed Diame sent two long-range efforts wide of the target, while N'Golo Kante nearly put through his own net after diverting a cross towards his own goal, but Newcastle's deserved opener finally arrived midway through the half.
Matt Ritchie's inswinging delivery set up Jacob Murphy for a half-volley from close range and although Courtois clawed the shot out, Gayle was perfectly placed to convert from close range for his sixth top-flight goal of the campaign.
Shelvey then lashed a shot wide from inside the penalty area before the increasingly-confident Gayle forced Courtois into a brilliant save low down to his left.
Perez got in on the act with a scuffed attempt which almost found the far bottom corner but from Chelsea's perspective, Antonio Conte's men reached the break having failed to register a single shot.
The Blues improved after the restart and Olivier Giroud almost netted a stunning equaliser, with the Frenchman nearly flicking the ball over Martin Dubravka on the half-volley only for the goalkeeper to get back to tip the effort over the crossbar.
Newcastle's level had dropped but it did not prevent the home side from doubling their advantage as Perez got the slightest touch to a Shelvey volley from outside of the area to divert the ball into the far corner of the net.
Ross Barkley should have halved the deficit from close range, only to see Dubravka stick out a foot to keep the ball out from six yards, and it ultimately led to Newcastle further extending their lead.
A deep free kick from the right was met by Florian Lejeune at the back post, and the defender's volley back across goal was converted by Perez for his second in the space of four minutes.
With the game over as a contest, neither side were prepared to put too much effort into the closing stages and the game naturally petered out, with Newcastle ending the season on a high and Chelsea left needing to regroup ahead of next week's FA Cup final with Manchester United.
NEWCASTLE UNITED (4-4-1-1): Dubravka; Yedlin, Lascelles, Lejeune, Dummett; Ritchie (Hayden 72'), Shelvey, Diame (Haidara 87'), Murphy; Perez; Gayle (Joselu 48')
CHELSEA (3-5-2): Courtois; Azpilicueta, Christensen, Cahill; Moses, Barkley (Willian 77'), Kante, Bakayoko, Emerson; Hazard (Pedro 82'), Giroud (Morata 76')