On a glittering night for Italy, Gabriele Detti won his first world title in a close finish in the men's 800m freestyle, an emotional Chad le Clos of South Africa took gold in the men's 200m butterfly and Britain's Adam Peaty secured a breaststroke double with 50m gold.
Pellegrini last won a world title at the 2011 championships, but the determined Italian rolled back the years to clock one minute 54.73 seconds.
The oldest in the field at 28, Pellegrini stormed back from fourth at the final turn to take gold ahead of Katie Ledecky of America and Australia's Olympic bronze medallist Emma McKeon, who had led until the 150m mark.
Peaty heroics not enough as USA pip Britain to 4x100m medley relay gold
In the process Pellegrini, who broke 10 world records before she was 21, scuppered the hopes of silver medallist Ledecky becoming only the second swimmer, after Michael Phelps, to win at least two world titles in four different individual events.
The final was given an extra dimension thanks to the inclusion of Katinka Hosszu, who finished seventh in a less favoured event for the Hungarian.
The raucous atmosphere inside the Duna Arena had barely subsided by the time her compatriot Lazslo Cseh stepped up to his centre lane blocks for the men's 200m butterfly.
The second-fastest qualifier, however, could not replicate his form of the heats as Le Clos regained the title he won at the 2013 championships.
Cseh held on for silver ahead of Japan's Daiya Seto.
Britain's Peaty again left the field trailing in the 50m as he secured a breaststroke double following 100m gold.
Peaty, 22, was denied a third successive world record time as he clocked 25.99 seconds. Joao Gomes of Brazil pipped Cameron van der Burgh into silver.
Detti's win was perhaps the most spectacular given that three swimmers were separated by just 0.09 seconds at the 750m mark.
Detti stormed home in a European record time of seven minutes 40.77 seconds ahead of Poland's Wojciech Wojdak and Italy's Gregorio Paltrinieri.
In the mixed 4x100m medley relay, the United States set their second world record of the day to take gold. Australia and Canada won silver and bronze respectively to end another frenetic evening. (Editing by Toby Davis)
Lilly King set new world record in 50m breaststroke
Russians take triple gold in Budapest as Manuel beats Sjostrom