The 35-year-old Haas is the oldest player in the top 100 and is looking for his second title of the year. Haas won another tournament in Germany, in Munich, also on clay.
Haas cruised through the first set, but Gulbis bounced back in the second. In the decider, Haas broke serve to win the match as Gulbis slammed a forehand into the net.
"There are days like that, I could feel that he couldn't find his rhythm in the first set but I was also struggling. This was my first match after Wimbledon, switching from grass to clay," Haas said.
"In the second, he got some first serves in and they are difficult to return. But I also served well at the end."
Haas will next play fifth-seeded Fabio Fognini of Italy, who overwhelmed Leonardo Mayer of Argentina 6-1, 6-3.
Fourth-seeded Benoit Paire of France also won his second-round match by beating Nikolay Davydenko of Russia 6-3, 6-1.
Paire's quarterfinal opponent will be Victor Hanescu of Romania, who beat Thomaz Bellucci of Brazil 6-1, 6-4.
Hanescu leveled his record against Bellucci to 1-1.
Paire advanced to the quarterfinals in Stuttgart for the first time, having twice lost in the second round previously.
In other quarterfinals, Michael Berrer of Germany faces Roberto Bautista Agut of Spain, while second-seeded Philipp Kohlschreiber of Germany meets Gael Monfils of France.
Results from the fourth day of the ATP Stuttgart Open (x denotes seeding):
Victor Hanescu (ROM) bt Thomas Bellucci (BRA) 6-1, 6-4
Benoit Paire (FRA x4) bt Nikolay Davydenko (RUS) 6-3, 6-1
Fabio Fogini (ITA x5) bt Leonardo Mayer (ARG) 6-1, 6-3
Tommy Haas (GER x1) bt Ernests Gulbis (LAT) 6-0, 3-6, 6-4