Agassi, who had taken some time off to heal a wrist injury and to marry the actress Brooke Shields, looked sharp in the first set with a crackling serve and effective passing shots, but he then weakened. Agassi won an early break in the second set but eventually dropped the set when he double- faulted on break point in the ninth game.
Agassi again took the early lead in the third set before Flach broke in the fifth and ninth games.
"I wasn't expecting a whole lot after not having played in a couple of months," said Agassi, whose ranking has fallen from No 3 to No 31 in the past 12 months.
Agassi also launched an attack afterwards on the game's administrators. "Something has got to be done for the game. Tennis needs to change the entire structure. It needs an off-season. It needs a ranking change. It needs to get people who know what the hell they are doing to be quite honest."
Agassi had a poor first-serve percentage of 46 per cent and was guilty of 15 double-faults, including two on game points.
Flach, who has a ranking of 174, had 10 aces, including four in a row at one stage and a bullet down the middle that ended the match.
"I was pretty surprised myself with those aces, but my serve has been improving lately," said Flach, who eliminated Agassi in the first round at Wimbledon last year. "In fact, my whole game has picked up and I've won matches in my last three tournaments."
Another former Wimbledon champion, Boris Becker, and the French Open champion, Gustavo Kuerten, were early casualties at the Mercedes Cup in Stuttgart yesterday. A calf injury prevented Becker from starting his third-round match against the Spanish ninth seed, Albert Costa, while Kuerten had to retire in his match against the 10th seed, Felix Mantilla, in the first set because of continuing problems with a chest muscle.
The Brazilian eighth seed held up his racket in surrender during the sixth game, when he was 4-1 down, giving Mantilla an easy passage into the quarter-finals.