Toffees defender Jarrad Branthwaite had nodded Iliman Ndiaye's inswinging corner in off the upright to open the scoring on 19 minutes after a cagey start to the contest at St. James' Park, but Jacob Ramsey's deflected drive swiftly levelled matters.
Beto pounced just after the half hour to prod home from close range and give his side a half time lead, after goalkeeper Nick Pope could only parry Dwight McNeil's effort from the edge of the box.
Eddie Howe's charges dominated the second half, and Jacob Murphy's deflected volley from a Joelinton cross looked to have earned them a share of the spoils with less than ten minutes remaining.
But just seconds later, Barry turned Kiernan Dewsbury-Hall's cross in to put the Toffees back in front.
Amid a chaotic finale on Tyneside, the Magpies could have snatched a point in stoppage time, but Sandro Tonali's stunning volley was kept out - equally impressively - by Jordan Pickford at full stretch.
United head coach Howe had made six changes to his side for the visit of David Moyes' men, with Pope, Lewis Hall, Malick Thiaw, Ramsey, Anthony Elanga and former Everton forward Anthony Gordon all restored to the line-up.
Ndiaye lifted a 25-yard effort well over Pope's crossbar early on, while Joelinton curled a shot over after Gordon's lay-off before Branthwaite struck, glancing home Ndiaye's delivery via the post.
United struggled to carve out any gilt-edged chance in the first half hour, with Joelinton seeing a tame header held by Pickford and Elanga shooting straight at the England stopper from distance.
After Tonali picked him out on the edge of the box, though, Ramsey's drive restored parity - but only momentarily, as Beto capitalised on Pope's misdirected parry to put the Toffees back in front from close range.
Pope saved comfortably from McNeil soon after the restart, while Kieran Trippier whipped a free kick wide of the target before the hour as Newcastle sought a second equaliser of the afternoon. A spell of pressure from United followed, with Gordon cutting inside and seeing his low shot parried by Pickford, with some last-ditch defending from Beto and James Tarkowski preventing the rebound from being turned in.
The hosts were enjoying the vast majority of possession but with 25 minutes left, Everton squandered a golden opportunity to extend their advantage. Beto pursued a loose ball to the touchline alongside Thiaw, and though the ball looked to have gone out of play, referee Stuart Attwell allowed the game to continue as Beto ran clean through on goal. Under pressure from Tonali, his shot clipped the crossbar as boos rang round St. James'.
Substitute Harvey Barnes - sent on with Murphy as Howe looked for a spark - cleared the crossbar when a Trippier cross fell his way via a touch from Pickford and another replacement, Joe Willock, also fired over as the hosts continued to push.
With Yoane Wissa also deployed from the bench, Gordon and Barnes both saw shots blocked before Murphy connected well with Joelinton's lofted centre to level once more, with the winger's effort taking a touch off an Everton defender on its way past Pickford.
But after the Magpies surrendered possession deep in their own half, Dewsbury-Hall burst into the box and Toffees substitute Barry - under pressure from Lewis Hall - turned home the cross to stun the United faithful.
And the Toffees were indebted to Pickford for protecting their three points with a fine save at the end to deny Tonali, whose volley looked destined for the top corner before the the visitors' stopper turned it onto the crossbar.
Newcastle United: Nick Pope, Kieran Trippier (c) (Yoane Wissa 76), Lewis Hall, Joelinton, Sandro Tonali, Anthony Gordon (Will Osula 86), Malick Thiaw, Anthony Elanga (Jacob Murphy 56), Nick Woltemade (Harvey Barnes 56), Dan Burn, Jacob Ramsey (Joe Willock 46)
Subs not used: Aaron Ramsdale, Sven Botman, Alex Murphy, Leo Shahar




