WASHINGTON—The U.S. budget deficit narrowed further in May as revenue continued to rise faster than expenses have in the past year, the Treasury Department said Wednesday.

The budget picture has improved this year amid higher tax revenue and stronger economic growth, even though government spending has also increased. Revenue for the fiscal year, which began in October, is running 9% ahead of the year-earlier levels, while government spending is up 6%.

In the past 12 months, the budget deficit has fallen to $412 billion, down from $460 billion in April and $491 billion a year earlier. That marks the lowest 12-month deficit since August 2008.

The brighter budget outlook means the deficit could come in below projections made by analysts just a few months ago. The Congressional Budget Office forecast in March that the federal deficit would rise to $486 billion this year, from $485 billion last year.

The U.S. ran an $82 billion deficit in May, a month in which the government has almost always run a deficit in recent decades. The government collected $212 billion in receipts, up 6% from a year earlier, and spent $295 billion, essentially unchanged after adjusting for calendar differences.