Agassi, who replaced Lleyton Hewitt at the top of the world rankings last week, overwhelmed Ferrer with the precision of his groundstrokes in a one-sided first set.
The Spaniard, however, refused to buckle and took the second set into a tiebreak.
Ferrer earned a mini-break by forcing Agassi into a forehand error and then levelled the match with a beautiful lob over the American.
Ferrer broke Agassi in the third game of the decider but the 33-year-old replied immediately, hitting shots deep to the baseline and forcing his opponent into unforced errors to level the score at 2-2.
Both players failed to capitalise on break points in the sixth and seventh games of the set but, in the ninth, Agassi gifted Ferrer the break with a double fault.
World number 60 Ferrer served out for the match to complete his unexpected victory.
First round results
David Ferrer bt Andre Agassi 0-6 7-6 (7-3); 6-4; Ivan Ljubicic bt Xavier Malisse 6-2 6-4; Victor Hanescu bt Mikhail Youzhny 7-6 (7-1) 6-3; 15-Guillermo Coria (Argentina) beat Tim Henman (Britain) 6-2 6-1; Felix Mantilla bt David Nalbandian 6-3 1-6 6-0; Mardy Fish bt Fabrice Santoro 7-5 7-5; Albert Costa bt Zelijko Krajan 6-4 7-5; Martin Verkerk bt Vincent Spadea 6-3 7-6 (7-2); Jiri Novak bt Wayne Arthurs 6-3 6-3; Dominik Hrbaty bt Thomas Enquist 6-3 6-3; Wayne Ferreira bt Feliciano Lopez 3-6 6-4 6-3.
German Open RESULTS
BERLIN: First round results from the $1.2 million German Open WTA tournament on Monday.
Virginia Ruano Pascual (Spain) bt Mary Pierce (France) 7-6 (9-7) - Pierce retired injured; Dinara Safina (Russia) bt Elena Dementieva 2-6 6-2 1-0 -Dementieva retired injured; Magui Serna (Spain) bt Silvia Farina Elia (Italy) 6-3 6-4; Maja Matevzic (Slovenia) bt Tathiana Garbin (Italy) 6-4 6-4; Jelena Kostanic (Croatia) bt Martina Mueller (Germany) 6-4 6-4; Marie-Gaianeh Mikaelian (Switzerland) bt Ai Sugiyama (Japan) 6-1 7-5; Nadia Petrova (Russia) bt Rossana Neffa-de los Rios (Paraguay) 6-3 6-2; Daja Bedanova (Czech Republic) bt Anna-Lena Groenefeld (Germany) 6-2 6-3; Nathalie Dechy (France) bt Clarisa Fernandez (Argentina) 6-0 6-4; Anca Barna (Germany) bt Anabel Medina Garrigues (Spain) 6-4 6-2; Barbara Schett (Austria) bt Laura Granville (U.S.) 3-6 7-5 6-3; Elena Likhovtseva (Russia) bt Henrieta Nagyova (Slovakia) 6-1 6-1.—Reuters