However, the 16-time Grand Slam champion says he expects to be ready for the Australian Open, which starts Jan. 16.
In a news conference 30 minutes before his match, Federer said his back muscle spasms had not improved since beating Andreas Seppi in three sets on Thursday.
Rafael Nadal will meet Gael Monfils in the other semifinal match on Friday.
Federer, who was looking for his fourth title in Doha, apologized to organizers but said he didn't want to risk further injury ahead of the Australian Open. It is only the second time the 30-year-old Swiss has pulled out of a tournament because of injury in his illustrious career.
"I don't feel a whole lot of improvement for today, and I just don't think it's the right time to risk anything more right now," Federer said. "I still have pain, and that's why it was the only right decision, a difficult one for me ... So it's a sad moment for me and for the tournament and for the fans, but health goes first."
Federer said he has tried several treatments including massage and baths after he first felt the injury Wednesday during his second round match against qualifier Grega Zemlja. He played against Seppi the next day but struggled to a three-set victory, trailing 5-1 during the second set and looking out of sorts. But afterward, he said nothing about the injury.
Federer said the injury started in the first set against Zemlja.
"Then I wasn't able to serve properly anymore," Federer said. "Had the same thing yesterday. I was really playing, you know, with the hand brake on, and I was just trying to manage the situation, really. So it wasn't very easy to deal with."
Federer said he plans to fly out of Doha on Saturday as scheduled and is hopeful he will recover with rest and treatment by the end of the week.
"For Australia, I'm optimistic, just because it's not very good but it isn't crazy bad," Federer said. "I have had bad backs in the past. This is definitely not very good; otherwise I would be playing. But I feel without play and the right treatment, I will get through it in the next few days."
Federer has been one of the few players on tour not to be slowed significantly by injuries over the years, his fitness one of the factors in his longevity. He used to only play an exhibition in Melbourne before the Australian Open. He now plays an exhibition in Abu Dhabi at the end of the year and the Qatar Open before heading to Australia.
Federer said he was physically and mentally fresh coming into this season and sounded confident that he would end his two-year Grand Slam title drought this season.
For that reason, Federer said he wanted to be cautious and not attempt to win the title in Doha.
"I've already played two matches in pain now, and it just gets a bit too much for the body," he said.
The sixth-ranked Tsonga said he was "sad" to hear of Federer's withdrawal as he was looking forward to the chance to face the player he lost to six times last year but beat in an epic five-set match at Wimbledon.
"It's good for me to play against him to see how is my level, how I feel, at the beginning of the season against a guy like this," Tsonga said. "I'm sad for him. I'm sad because I will not play."
Tsonga will play either Nadal or Monfils in Saturday's final.