Federer was due to play Australia's Lleyton Hewitt in the opening round.
"I've unfortunately had to pull out of the Gerry Weber Open in Halle, Germany," said the Swiss world number three.
"I am very disappointed as it is one of my favorite tournaments on the ATP World Tour, but my body and especially my groin need a rest after the French Open."
"After talking with my team this morning, I feel that it is too big a risk to take a chance and aggravate it before Wimbledon."
But tournament organisers were left fuming over Federer's withdrawal.
"All the plans throughout the year were almost exclusively focused on Roger's start here," said tournament director Ralf Weber.
"He also never indicated that there could be health problems there. I made my disappointment clear to his management."
The small Halle event is seen as a lower-key Wimbledon preparation event than the Queen's Club tournament in London.
- ReutersTags: sport, tennis, germany