Premier League: Swansea City 1 Everton 2
After a goalless opening period, Seamus Coleman produced a sensational strike to put the visitors ahead in the 66th minute.
But Swansea pulled level against the run of play four minutes later as a close-range Dwight Tiendalli effort deflected in off Bryan Oviedo, who was credited with the own goal, before Barkley netted a superb free-kick in the 84th minute.
Barkley's stunning goal - his third of the season - ensured former Swansea manager Roberto Martinez enjoyed a winning return to his old club as Everton made it 10 games unbeaten in the league.
The result lifts Everton to fourth, one point ahead of Chelsea, who meet Arsenal on Monday, while Swansea remain 11th.
Michael Laudrup made five changes to the Swansea side that drew 1-1 at Norwich City last Sunday, with injured trio Michel Vorm, Nathan Dyer and Michu among those to drop out, while Chico Flores and Wilfried Bony came back into the starting XI.
Martinez made two alterations from Everton's 4-1 win over Fulham last time out - James McCarthy and Kevin Mirallas replacing Leon Osman and the injured Gerard Deulofeu.
It was the hosts who applied the early pressure, but Wayne Routledge sent the first opportunity out for a throw-in after being teed up by Jonjo Shelvey.
Mirallas worked his way into the Swansea penalty area in the 14th minute, but, after sending Ben Davies one way and then the other, the Belgian drilled an effort straight at goalkeeper Gerhard Tremmel.
Swansea were almost left red-faced after 20 minutes, as Tremmel spilled the ball at the feet of Romelu Lukaku from a free-kick, but the German stopper recovered just in time to gather.
Routledge played in Bony as the game reached the 30-minute mark, but the Ivorian scooped his effort well over the crossbar in a half that saw Swansea fail to register a single shot on target.
Everton unlocked the Swansea defence in the 56th minute, with Lukaku playing Barkley into space, but the young English prospect slipped in the penalty area and failed to get any purchase on his eventual effort.
Barkley had Everton's best chance of the match moments later, unleashing a thunderous strike from 18 yards that was touched onto the crossbar superbly by Tremmel.
But the visitors broke the deadlock with their next attack. Coleman - a constant threat down the right – received the ball some 25 yards out, took a couple of steps goalwards and smashed an unstoppable effort into the back of the Swansea net for his fourth goal of the season.
Swansea were level against the run of play four minutes later, as Tiendalli prodded home a Davies cross from close range via a Oviedo deflection – the hosts' first goal against Everton since February 1983.
The game looked to be heading for a draw until Barkley fired in a wonderful free-kick off the underside of the crossbar from 20 yards to snatch maximum points for Everton. Tim Howard was called into action late on to make a reaction save from a close-range Pablo Hernandez effort.