The hosts raced into a 2-0 lead through Sam Winnall and Marley Watkins but Everton responded with an acrobatic Kevin Mirallas strike and a Steven Naismith header.
Daniel Crowley drove the Tykes back in front but Romelu Lukaku swept home to send the match to extra time.
Marc Roberts put through his net before Lukaku ended the thrilling cup tie.
Conor Hourihane had rattled the bar with a curling shot in the second period of extra time, but the League One side's fatigue told as Everton wrapped up the victory.
But they were pushed all the way by an adventurous Barnsley side who forced the Premier League side into errors and posed a constant threat going forward.
The Toffees - for whom Chelsea target John Stones played the full 120 minutes against his former club - will now travel to Reading in the third round.
Everton made a statement by including Stones in their line-up.
The 21-year-old England defender has handed in a transfer request to try and force through a move to Chelsea, who have had a third offer of £30m turned down.
It was a clear signal that, for now, he is part of Everton's plans - but the stresses of his situation appeared to show on the youngster who has been outstanding so far this season.
Stones, back at his first club, was not his usual composed self and made an error of judgement when Winnall gave the home side the lead, inexplicably stepping over his goalbound shot.
The defender received a mixed reception from Everton's fans but he, and Roberto Martinez's side, came through unscathed - and now he must wait to see what the next move on his future will be before Tuesday's transfer deadline.
Everton manager Roberto Martinez has made the Capital One Cup a priority this season as this is the competition that has got away from the club over the years.
And he played a relatively strong side, with Lukaku up front and Stones and Phil Jagielka forming an established central defensive partnership.
There were still risks with some changes and it was reflected in the fact he needed to bring on Gerard Deulofeu and Ross Barkley to rescue a 2-0 deficit at half-time.
The inclusion of Aiden McGeady was mystifying, as proved by the young Spaniard's sensational game-changing display.
Everton survived a major League Cup scare at Barnsley with two goals in extra time goal sending them through.