WASHINGTON — The United States has now spent $1 trillion more than it's taken in for four straight years.

The Treasury Department confirmed Friday what was widely expected: The deficit for the just-ended 2012 budget year — the gap between the government's tax revenue and its spending — totaled $1.1 trillion.

It wasn't quite as ugly as last year.

Thanks to a slightly healthier economy, revenue rose 6.4 percent from 2011. And government spending fell 1.7 percent to $3.5 trillion. That reflected, in part, less defense spending as U.S. military involvement in Iraq was winding down and less spending on Medicaid.

As a result, the deficit shrank 16 percent, or $207 billion.

A stronger economy meant more people had jobs and income that generated tax revenue. Corporations also contributed more to federal revenue than in 2011.

Barack Obama's presidency has now coincided with four straight $1 trillion-plus annual budget deficits — the first in history and an issue in an election campaign that ends in 3½ weeks.

When Obama took office in January 2009, the Congressional Budget Office forecast that the deficit that year would total $1.2 trillion. It ended up at a record $1.41 trillion. The increase was due, in part, to higher government spending to fight the worst recession since the Great Depression.