WASHINGTON – Homebuilders in the United States turned less pessimistic in May as a government tax credit increased sales.

The National Association of Home Builders/Wells Fargo confidence index rose to 22, exceeding the median forecast of economists surveyed by Bloomberg News and reaching the highest level since August 2007, data from the Washington-based group showed Monday.

Americans rushed to sign contracts ahead of an April 30 deadline for a tax credit of as much as $8,000, spurring demand and trimming the inventory of unsold properties. While lower prices and borrowing costs have brought houses within reach of more buyers, additional job gains are needed to sustain demand and limit foreclosures that depress values.

“We’re seeing some enthusiasm among builders,” Daniel Penrod, senior industry analyst at the California Credit Union League in Ontario, Calif., said before the report. “The housing industry will gain some traction as we head into the summer months,” due in part to “great affordability.”

The index was forecast to rise to 20 from 19 in April, according to the median projection of 48 economists surveyed by Bloomberg. Estimates ranged from 17 to 23. The gauge, which was first published in January 1985, averaged 15 last year.

“Builders are more comfortable that the market is truly beginning to recover,” NAHB chief economist David Crowe said in a written statement. “Obviously, we still have a long way to go.”

The confidence survey asks builders to characterize current sales as “good,” “fair” or “poor” and to gauge the outlook for the next six months.

Builders in the Northeast led the improvement in May, with the index surging 14 points to 35, the biggest jump since monthly records began five years ago.