The Toffees moved into the top four as Roberto Martinez oversaw a precious victory on his return to the Liberty Stadium, with the visitors now unbeaten in their last 10 outings
After a laboured first half, the Toffees raced out of the traps in the second period. First Barkley rattled the bar via the fingertips of Gerhard Tremmel, though the German keeper was powerless to stop an even more ferocious effort from Seamus Coleman moments later.
The visitor's lead was quickly wiped out, though, as Dwight Tiendalli profited from some suspect Everton defending to toe-poke a lose ball towards goal. His effort appeared to be going wide but ricocheted off Bryan Oviedo and deceived Tim Howard.
With the clock running out, Everton were awarded a free-kick on the edge of the box. Barkley stepped up and curled a powerful effort in at the near post to claim all three points and secure a first win for Martinez over his old club.
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 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, playing at a faster pace in the second period, 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. Howard was called into action late on to make a reaction save from a Pablo Hernandez effort, but the Toffees held on to move into fourth place.