The 19-year-old from Plymouth, in only his fifth appearance for the club, scored in the 118th minute to finally break the spirit of 10-man Liverpool.
Everton now face Aston Villa in the fifth round on February 15.
Liverpool ended in disarray. Robbie Keane sold, Steven Gerrard limping away after just 16 minutes, while Fernando Torres was withdrawn, exhausted, in extra-time.
They had been facing defeat from the moment Lucas was sent-off with 14 minutes of normal time left.
The Brazilian midfielder became the 23rd player to be dismissed in Merseyside derbies, with 16 of those coming in the last 10 years.
It summed up a fourth-round replay that was a war of attrition from the start between sides meeting for the third time in 17 days.
Everton had Marouane Fellaini back from suspension after missing the two derbies last month, while Liverpool left out Javier Mascherano and Fabio Aurelio, utilising Lucas and Andrea Dossena.
A simmering disdain was obvious. A match that was once the friendly derby turned into a nasty, spiteful one.
Neither manager had helped in the build-up as they sniped away at each other.
Reds boss Rafael Benitez had moaned about Everton's defensive tactics and physical approach while David Moyes claimed Liverpool were treated leniently by officials while asking for referee Alan Wiley to take a firm stance.
On the pitch the atmosphere was no better, and the Staffordshire official needed to be right on top of things.
He booked Tim Cahill after just 19 minutes for a flaying arm into Jamie Carragher's face, and lectures were dished out to Xabi Alonso, Lucas, Fellaini and Steven Pienaar.
There had been disruption for both sides beforehand.
Everton left out Victor Anichebe from their squad following his training-ground bust-up with Moyes, while Liverpool were surely distracted by the Keane saga.
And with the ink barely dry on transfer forms that had taken him back to Spurs, it was predictable that Liverpool found need for the Irishman after just 16 minutes.
They suffered the a savage blow when Gerrard pulled up with a hamstring problem and was replaced by Yossi Benayoun. If Keane had been around he would have been the ideal replacement to play behind Torres.
As it was Dirk Kuyt was shifted into a more central role, and Liverpool had lost their driving inspiration.
Liverpool tried to impose their passing game on Everton, who responded in their usual way.
Pienaar was booked a foul on Lucas, while the only genuine shots in the first half came from Alonso with a 25-yarder that skidded wide, while Leon Osman volleyed over from the edge of the box.
The second period started with Benayoun and Kuyt switching roles while Phil Neville and Lucas both picked up bookings.
Everton were soon to lose the injured Fellaini, teenager Gosling taking over.
That left Everton without any real threat in the air, and they were forced into another change when Pienaar - who had seemed to be struggling with a hamstring problem - was replaced by youngster Jack Rodwell.
Tim Howard needed to make a decent smothering save when Alonso's angled pass sent Albert Riera into the box.
Mikel Arteta had been pushed forward to help Cahill, Everton's resources stretched almost to breaking point.
Chances were rare. A Gosling shot failed to worry Jose Reina, while Howard pulled down a Kuyt header.
Liverpool's own sloppiness eventually allowed Everton the best chance so far.
Possession was squandered and Arteta passed for Leon Osman to hit a post.
Arteta was booked for a foul on Riera, but after 76 minutes Liverpool were reduced to 10 men when Lucas's daft trip on Joleon Lescott gave Wiley no choice but to brandish a second yellow and then red.
Mascherano was soon sent on to shore up the centre, Riera being sacrificed.
The flow of cards continued. Alonso being cautioned for a foul on Tony Hibbert with a minute of normal time to go.
In the first period of extra-time, Everton penned Liverpool back, Cahill having two efforts wide and missing a Leighton Baines cross.
Osman also went close twice before Liverpool took off Torres - played off the park by Phil Jagielka - and sent on Ryan Babel.
Andy van der Meyde came on for Neville, Everton searching for the moment to break Liverpool's resistance. Hibbert became Everton's fifth booking for a foul on Alonso.
And in the 118th minute, Everton went ahead.
Van Der Meyde's cross from the right was controlled by Gosling on the left, and his deflected shot went in off the far post.
Cue mass hysteria.