Everton right-back Seamus Coleman broke the deadlock in the 66th minute with a swerving 30-yard shot, but Swansea equalised four minutes later when Dwight Tiendalli's volley deflected in off Bryan Oviedo.
Barkley settled matters at the death, bending a sumptuous free-kick in off the crossbar from just outside the box to give Everton manager Roberto Martinez victory against his former club.
The victory left Everton in fourth place, a point above Chelsea, having played a game more, while Swansea remain 11th.
Liverpool deposed Arsenal as league leaders on Saturday with a 3-1 win at home to Cardiff City, while Manchester City moved up to second place by winning 4-2 at Fulham.
Arsenal can return to the top of the table by beating Chelsea at the Emirates Stadium on Monday, but Jose Mourinho's visitors will draw level on points with Liverpool if they prevail.