Federer, who faces Germany's Florian Mayer in Friday's quarter-final, squandered 10 of his 13 break points against Hajek, including five match points in the eighth game of the second set, but prevailed in 72 minutes.
Jan Hajek of Davis Cup holders the Czech Republic lifted his team 1-0 up against the hosts Kazakhstan in Astana on Friday, beating local favourite Mikhail Kukushkin in straight sets on Friday.
On paper, Somdev was no match for his 106th ranked Czech opponent but India's top singles player proved his fitness which is a positive sign ahead of country's Davis Cup tie against South Korea in Delhi.
Novak Djokovic may not be off to another perfect start to the year, but at least he is consistent when it comes to winning his opening match at the ATP/WTA Indian Wells Tournament.
Rafael Nadal launched his US Open title defence with a battling 6-3, 7-6 (7/1), 7-5 victory over Andrey Golubev of Kazakhstan, but the straight-sets win was anything but easy.
Juan Monaco defeated Andrey Golubev 6-3, 6-0, 6-4 to give Argentina a 1-0 lead over Kazakhstan in the Davis Cup quarter-finals on Thursday.
Kazakhstan took a 1-0 lead over the Czech Republic after Andrey Golubev outlasted Jan Hajek 7-6 (4), 6-7 (3), 1-6, 7-6 (4), 6-3 in the opening singles match in the first round of the Davis Cup on Friday.