It was Federer's first loss to a German since Nicolas Kiefer's semifinal win, also in Halle, 10 years ago.
"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, a former second-ranked player whose career has been blighted by injuries.
Now ranked 87th, Haas was the oldest player in the singles draw at 34. He recovered from losing his serve in the opening game of the match, and broke decisively in the ninth game of the second set.
"I'm very impressed with how he played today," Federer said. "Tommy deserved to win."
The second-seeded Federer was bidding for his fifth tour title of the season and 75th overall.
It was Haas' first win over his good friend in 10 attempts, and his third overall against the 16-time Grand Slam champion from 13 meetings.
"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 broke to lead 5-4 after a lengthy rally featuring lobs, chips and a drop shot, following two unforced errors in succession from Federer that allowed him to force deuce.
Haas last won the grass-court tournament in 2009, beating Novak Djokovic in the final.
He hadn't appeared in a final since then, so nerves perhaps played a role in his loss of serve in the first game. Both players had only been broken once this week.
Federer missed another break point in the fifth game to leave the score at 3-2. Haas levelled by breaking in the next after Federer uncharacteristically hit a simple return into the net.
Haas missed two break chances with the score at 5-4 to win the set, sending a return long and not dealing with another. Federer eventually won the game with his fifth ace to level at 5-5.
"I should never have lost the first set, so that hurt. He got momentum after that," Federer said.
The Swiss managed a mini-break in the tiebreaker on Haas' first serve, but the German came back to establish a 4-2 lead.
A fan of Haas called for him to fire an ace, and there was a huge roar from the crowd when he duly obliged to move the score to 5-3.
Another mini-break put the German in a position to win the set, and he didn't let it slip.
"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."
It was the first final in the 20-year history of the tournament to feature two players aged 30 or older.
"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," said the 30-year-old Federer.
Federer's only previous Halle final loss was in 2010 to Lleyton Hewitt.Suggest a correction