"If someone had told me beforehand that I'd win the title here against probably the greatest player of all time, I would not have believed it," said Haas, who has been ranked as high as No. 2 in the world but struggled with injuries.
The 87th-ranked Haas, the oldest player in the singles draw at 34, recovered from losing his serve in the first game by winning the opening set in a tiebreaker and then getting the decisive break in the ninth game of the second set.
"I'm very impressed with how he played today," Federer said of his good friend. "Tommy deserved to win."
Haas beat Federer in two of their first three meetings early in their careers but hadn't defeated the Swiss great in more than a decade, losing their last nine matchups.
"It was a long time coming since I had the chance to get to that point," said Haas, who started the season outside the top 200.
"It's my 13th title. ... It's probably up there (as the best), if not the sweetest one, especially considering the injuries."
Haas got the break to earn a 5-4 lead after a lengthy rally featuring lobs, chips and a drop shot. That followed two unforced errors in succession from Federer that allowed him to force deuce.
Haas last won the grass-court tournament in 2009, when he beat Novak Djokovic in the final. He hadn't appeared in a final since then, so perhaps nerves played a role in his loss of serve in the first game. Both players had been broken only once this week.
"If I thought about it, this would be the perfect way to say goodbye to tennis. Beating Roger, my 13th title. It would be perfect. But I'm not ready mentally," Haas said. "I hope the body holds up for many years to go. I love to play."
Federer missed another break point in the fifth game to leave the score 3-2, and Haas pulled even by breaking him in the next game, when Federer uncharacteristically netted a simple return.
"I should never have lost the first set, so that hurt. He got momentum after that," the 30-year-old Federer said.
With Haas leading 4-3 in the tiebreaker, a fan called for him to fire an ace, and there was a huge roar from the crowd when he duly obliged with his third.
"I'm just really happy for him ... happy that he's been able to fight off so many injuries and come back and still believe in himself, still want to travel, still want to sacrifice his family (life) too," Federer said of Haas.
It was the first final in the tournament's 20 years to feature two players 30 or older.
The second-seeded Federer was bidding for his fifth tour title of the season and his 75th overall. His only previous final loss in Halle was in 2010, when he lost to Lleyton Hewitt.