The closely watched Ifo indicator rose for the second consecutive month to 84.2 from 83.7 in April, adding to evidence that sentiment is again on the up in Germany, the world's top exporter.
The result was slightly worse than expected, though. Analysts surveyed by Dow Jones Newswires had expected the index to rise to 85.0.
The survey "points to a gradual stabilisation of economic output at a low level," the Ifo institute's head Hans-Werner Sinn said in a statement.
Economists see the index as a key leading indicator to gauge the future health of the economy. It had been falling steadily - with occasional blips - since June 2008 as sentiment among firms plummeted due to the financial crisis.
Tempering the optimism, however, was a sub-index showing that companies' assessment of the current situation in Germany dropped in May to 82.5, its lowest level ever.
But the brighter outlook from the 7,000 German firms surveyed is the latest in a string of more positive data, with industrial orders and exports showing their first increases in March after falling for several consecutive months.
Another closely-watched sentiment index, which measures the outlook of players in the financial markets, also rose to a near three-year high in May after a seventh rise in a row, data from the ZEW institute showed on Tuesday.