The Swiss, playing his first match in two months, won the first set but succumbed to the German in the second-set tie-break having had match point.
"It's always special to play a close friend like Roger on grass, always lots of emotion," said the world 302.
"I saved a match point so was able to play more freely after that."
He added: "I even shocked myself."
It was Haas' fourth victory in 17 meetings against the former world number one.
The 35-year-old, who has started his build-up to Wimbledon, had not played since winning the Miami Open against Rafael Nadal in April and missed the entire clay court season.
It was only the world number five's second defeat of the 2017 season.

The 22-year-old, who scored 20 goals last season, has started in both of the Baggies' league games this season.
"We have no interest in selling Saido which is what I have told Spurs chairman Daniel Levy," said Albion chairman Jeremy Peace.
"I know we are living in an age where no club can say 'never' about the possibility of selling a player."
He added: "However, the prospect of selling Saido is simply not on our agenda.
"We are going forward with Saido very much in our plans and still striving to add players to improve the balance of our squad."
The Daily Telegraph reports the offer from Spurs is worth £15m, with Albion valuing Berahino at £25m.
In February, Baggies boss Tony Pulis said he put Berahino "on the naughty step" after the forward said that "he hoped to move on to bigger things".
Berahino, with 14 strikes, was the third top English scorer in the Premier League last season behind Spurs' Harry Kane and QPR striker Charlie Austin.

McClaren, under pressure with the Magpies 19th in the Premier League, took training as scheduled on Tuesday.
The board - minus the ex-England boss - met away from Tyneside on Monday.
Newcastle are in danger of a second relegation in seven years after five defeats in six league games, including Saturday's 3-1 loss to Bournemouth.
On Monday, managing director Lee Charnley, chief scout Graham Carr and club ambassador Bob Moncur discussed possible ways forward with 10 games of the season remaining.
McClaren took over in the summer after leaving Championship side Derby but has only won six of his 28 top-flight matches in charge.
Former club owner Sir John Hall claimed the 54-year-old should be sacked, while Alan Shearer, Newcastle's record goalscorer, has described the club as a "mess from top to bottom."
The NUFC Fans' Forum - a representative body of supporters' groups - has called for action to be taken in an open letter to the club's hierarchy.
Seven-time Wimbledon champion Roger Federer was beaten 2-6 7-6 (10-8) 6-4 by 39-year-old Tommy Haas on grass at the Stuttgart Open.
[NEXT_CONCEPT]
West Brom have rejected an offer from Tottenham for England Under-21 striker Saido Berahino.
[NEXT_CONCEPT]
Steve McClaren remains in charge of Newcastle United, with a board decision on his St James' Park future expected in the next 48 hours.