Hanescu won the first-set tiebreaker on his third set point when Djokovic hit a forehand long.
"It's a big relief to win ... this is a big boost up for upcoming matches,'' Djokovic said. "He used his biggest weapon which was his serve. (And) I coudn't find any rhythm in return, so he used that wisely.''
Hanescu saved a set point in the second set by hitting a powerful forehand to catch the third-ranked Djokovic going the wrong way in the 12th game.
The 1.98-meter (6-foot-6) Hanescu trailed 4-1 in the ensuing tiebreaker before leveling at 5-5. But Djokovic finally evened the match on his second set point with a crisp backhand passing shot.
Top-ranked Rafael Nadal pulled out of doubles play with Carlos Moya on Tuesday due to a slight upper leg injury.
"Every match is important, including doubles, but I've got priorities,'' said Nadal, who next faces Richard Gasquet of France in singles on Thursday. "You can't win everything.''
American qualifier Robby Ginepri scored the day's biggest upset by beating fifth-ranked Nikolay Davydenko 4-6, 6-4, 6-4.
Davydenko, who started well to take the first set, hit 35 winners to 15 for Ginepri, but committed 53 unforced errors over the final two sets.
Davydenko failed on three break opportunities in the ninth game and Ginepri took the set when the Russian netted. The 63rd-ranked American clinched it when the Russian double-faulted to be broken.
Sixth-ranked David Ferrer soon followed Davydenko out of the tournament after falling 6-4, 7-6 (4) to Feliciano Lopez in an all-Spanish matchup.
David Nalbandian won his sixth straight match by defeating Tomas Berdych of the Czech Republic 6-2, 6-7 (5), 6-1.
"Last week I was playing really good, so I came here with confidence and I also like to play here,'' said Nalbandian, coming off a Stockholm Open victory. "I'm thinking one game at a time, step-by-step.''
Nalbandian next plays Davis Cup teammate Juan Martin Del Potro, who advanced after Jarkko Nieminen of Finland retired when trailing 6-2, 4-2.
Australian Open finalist Jo-Wilfried Tsonga advanced after rallying to beat Spanish qualifier Marcel Granollers 3-6, 6-3, 7-6 (5).
Tsonga will next face either second-ranked Roger Federer or Radek Stepanek, who play later Wednesday.
After a slow start, Tsonga won the second set thanks to his booming forehand and court speed.
"Behind me? I don't know, but I have to deal with it, and that's it,'' said Tsonga, playing his third tournament since returning from knee surgery last month. "I played well, like at the start of the year.''
Gael Monfils also advanced after eliminating 2006 finalist Fernando Gonzalez of Chile 6,3, 6-4.
Djokovic, Tsonga to meet in Thai final
Ginepri upsets Davydenko at Madrid Masters
Sporting Injury Worries Lessen