Two goals from Luis Boa Morte were no more than Fulham deserved after a first half in which Liverpool were agonisingly poor.
But the arrival of substitute Alonso at half-time completely changed the game as the Reds stormed back for a morale-boosting victory.
Fulham were left stunned and steamrollered as a fluke own goal from Zat Knight got Liverpool back in the game before Milan Baros equalised.
Not even a red card for Josemi for two bookable offences could stop the Liverpool comeback after that – and Alonso scored a superb free-kick to make it 3-2.
Fellow substitute Igor Biscan, only on the pitch for a few seconds, then made it 4-2 right on full time - to set off huge celebrations in the away end.
No-one could have predicted the result, either before the match or at half-time.
Neither team went into the match in confident form. Fulham were still reeling from a miserable 2-0 defeat at lowly Crystal Palace while Liverpool were trying to avoid their fourth away defeat in a row.
They may well have expected to end that run at Craven Cottage, where Fulham had failed to beat the Merseysiders since 1966.
But things have changed a lot in South West London since Fulham were thrashed 10-0 at Anfield in a League Cup tie during the dark days of lower division football only 11 years ago.
They ended their Liverpool jinx with a 3-2 Premiership win over the Reds at Loftus Road under Jean Tigana and looked determined to earn another three points this time.
Perhaps that's why Fulham started the stronger, while Liverpool looked disjointed and uninspired.
The home side almost took the lead after 20 minutes from a well-worked free-kick routine that ended with Mark Pembridge skimming a left-foot shot narrowly wide.
Then Fulham made it 1-0 after 23 minutes, after Salif Diao needlessly gave the ball away in midfield.
Steed Malbranque took full advantage, jinking a superb ball inside for Brian McBride, whose fierce low cross was turned in at the far post by Boa Morte.
The Portuguese international made it 2-0 six minutes later, once again he raced onto a superb Malbranque pass before drilling a left-footed shot between the legs of keeper Chris Kirkland.
With Liverpool looking dejected it seemed Fulham were on their way to a superb victory.
But the arrival of substitute Alonso for the awful Diao at half-time changed the game.
Suddenly Liverpool seemed inspired, and they go the break they so badly needed when Baros hit a shot that was heading way wide, but spun off Knight's chest and shoulder before ending up in the net.
It was a freak goal and it wasn't long before they grabbed an equaliser, this time without any need for luck.
Alonso swung over a superb cross that was flicked on by Luis Garcia forcing keeper Edwin Van der Sar into a point-blank save. But Baros was there to follow up and tap home an unlikely equaliser.
Suddenly, the whole match had swung Liverpool's way, and even when they were reduced to ten men after Josemi needlessly fouled Boa Morte for his second booking of the game, the Reds marched on.
Amazingly, they went 3-2 up when Garcia won a free-kick 25 yards out and Alonso curled a stunning shot into the net with Van der Sar nowhere to be seen in the 80th minute.
It was frantic stuff after that, and Alonso missed a glorious chance for 4-2 when he fired over from a Djibril Cisse cut-back in the 90th minute.
But Liverpool held on for a stunning victory and then grabbed a fine fourth on the break when Biscan ended a flowing move by scoring his first ever Premiership goal high into the top corner of the net.
Man of the Match: Xabi Alonso Only on for 45 minutes but easily the most influential player on the field, with a display that rescued the points for the Reds.