It marked the fourth straight year that deficits exceeded $1 trillion.
The deficit was down 16% from fiscal 2011 in dollar terms. And as a share of the economy it fell to 7%, down from 8.7% of gross domestic product in 2011. The fiscal year ended Sept. 30.
The decline is due to higher receipts and lower outlays.
Tax revenue was $2.45 trillion, accounting for 15.7% of GDP, slightly higher than in 2011 but well below the 18.3% historical average.
Revenue was boosted by the expiration of various tax provisions and a stronger economy, Treasury said in a joint statement with the White House budget office.
As is typical, individual income taxes accounted for the lion's share of total revenue -- $1.132 trillion.
Receipts from social insurance, including payroll taxes, totaled $845 billion.
Corporate receipts came in a distant third, at $242 billion, but grew strongly.
Spending, meanwhile, totaled $3.54 trillion, or 22.7% of GDP. That's below the 24.1% recorded in 2011 but still above the historical average of 20.7%.
Treasury attributed the drop to the expiration or phase down of stimulus measures, a stronger economy and the draw down of war efforts in Iraq and Afghanistan. Spending on the Department of Defense, unemployment insurance and Medicaid fell the most.
0The federal government spent $359 billion to pay interest on the country's debt. That includes interest paid both to investors who bought U.S. bonds and to government trust funds.
Treasury's numbers are largely in line with the 2012 spending, revenue and deficit estimates published last week by the Congressional Budget Office.
Deficits and debt have become a heated political issue and never more so than in the race for the White House. Not surprisingly, President Obama, the Democratic nominee, and Mitt Romney, his GOP challenger, have laid out very different routes to curbing deficits over the next decade.
|Don't fight it. Bitcoin has a bright future|
|"The Hobbit" dispute sparks lawsuit|
|Five things you didn't know about Bernie Madoff's epic scam|
|Teen millionaire helping Yahoo become cool again|
|Stocks falter as budget deal raises taper risk|
|Overnight Avg Rate||Latest||Change||Last Week|
|30 yr fixed||4.45%||4.52%|
|15 yr fixed||3.47%||3.55%|
|30 yr refi||4.44%||4.51%|
|15 yr refi||3.46%||3.54%|
Today's featured rates: