West Ham can now look forward to a fifth-round trip to Blackburn after a youthful Liverpool side were eventually sent tumbling out.
Michail Antonio had given the hosts the lead, only for Philippe Coutinho to reply for the Reds just after half-time.
But Ogbonna made it an uncomfortable evening to be a losing manager, not least one who had had his appendix removed just three days earlier like Jurgen Klopp.
The home fans knew this was likely to be the last FA Cup tie under the lights at Upton Park, and the famous old ground crackled with an atmosphere it will surely be impossible to recreate at the Olympic Stadium.
The match was worthy of the occasion, as well. In a breakneck first half alone, West Ham were twice denied by the woodwork, while Liverpool also rattled a post before Antonio broke the deadlock.
Hammers full-back Joey O'Brien was first to be frustrated by the frame of the goal when his shot was deflected against the base of Simon Mignolet's upright.
But Liverpool's rookies, aided by the experience of Coutinho and out-of-favour striker Christian Benteke, looked the more dangerous in the early stages.
The senior duo combined when Benteke reached the byline and cut the ball back for Coutinho, whose first-time shot clipped an upright.
Moments later West Ham playmaker Dimitri Payet, reportedly the subject of a big-money bid from a Chinese club, curled a superb free-kick against the post.
Antonio headed the rebound back towards goal but Mignolet did brilliantly to scramble back to his feet and make a diving save.
The breakthrough came on the stroke of half-time when Enner Valencia crossed to the far post, where Antonio side-footed a volley into the back of the net.
Yet the lead lasted less than three minutes of the second half, after Liverpool were awarded a free-kick on the edge of the box.
Coutinho shaped to curl the ball over the West Ham wall, but as the players jumped the Brazilian cheekily drove it underneath them and past startled goalkeeper Darren Randolph.
West Ham were convinced they should have had a penalty when Tiago Ilori pulled back Valencia as he attempted to reach Antonio's cross, but referee Roger East did not agree.
Valencia could have won in normal time but headed Payet's cross over, while Benteke and Jordon Ibe forced saves from Randolph.
Early in extra time Mignolet was in action again to palm away a curler from Mark Noble before Benteke passed up two clear-cut chances, blazing wide from 16 yards before firing too close to Randolph.
Then England striker Daniel Sturridge, on as a substitute for Liverpool after another spell out injured, fired a rasping drive inches over the crossbar.
But as the clock ticked down Ogbonna trotted forward and managed to get his head to Payet's free-kick to spark delirious scenes among the Upton Park faithful.
We look at some of the issues surrounding the game.
WILL JURGEN KLOPP BE FIT?
The German returned to work less than 48 hours after having his appendix removed and will travel with the team to Upton Park, although he admits he will have to subdue his usual over-active behaviour on the sidelines. Apart from "a few holes" in his body Klopp insists he is raring to go having taken Monday training.
CAN KLOPP RISK PLAYING THE YOUNGSTERS AGAIN?
West Ham manager Slaven Bilic has pledged to field a strong team but Klopp has so far played below-strength sides as he tries to offset significant fixture congestion.
In the first encounter he played seven first-teamers - although only three were regulars - in an attempt to avoid a replay but with their league form so inconsistent it may be time to concentrate on the cups.
IS THIS THE MOMENT FOR DANIEL STURRIDGE?
The much-injured England international has not played for two months but, ahead of schedule, he was a surprise inclusion as an unused substitute for Saturday's draw against Sunderland. If he is deemed fit enough to be on the bench then Klopp may as well give him a run from the off as in his four starts this season he has scored four goals.
DOES THE FAVOURITES TAG SIT WELL WITH WEST HAM?
It should. So far this season they have scored five goals without answer in the two league matches against the Reds and while they have never beaten them three times in the same campaign Liverpool's inconsistency, added to their fixture fatigue, plays into the hands of the hosts.
SHOULD THE HAMMERS BE PRIORITISING THE CUP OVER THE LEAGUE?
The sixth-placed Hammers are unlikely to make a late challenge for a Champions League spot so what better way to open their new home next season than with a shiny piece of silverware to parade around the Olympic Stadium.
With Blackburn, six points off relegation in the Championship and having just sold leading scorer Jordan Rhodes, awaiting in the next round a quarter-final place is there for the taking.
That looks even more inviting when you consider there are three all-Premier League fifth-round ties.
COMMENT RULES: Comments that are judged to be defamatory, abusive or in bad taste are not acceptable and contributors who consistently fall below certain criteria will be permanently blacklisted. The moderator will not enter into debate with individual contributors and the moderator’s decision is final. It is Belfast Telegraph policy to close comments on court cases, tribunals and active legal investigations. We may also close comments on articles which are being targeted for abuse. Problems with commenting? email@example.com