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.
|2 million Facebook, Gmail and Twitter passwords stolen in massive hack|
|Ron Paul: Bitcoin could 'destroy the dollar'|
|Pentagon to cut jobs, contracts by $1 billion|
|5 ways identity thieves are targeting you|
|A new normal for government retirees|
|Overnight Avg Rate||Latest||Change||Last Week|
|30 yr fixed||4.52%||4.38%|
|15 yr fixed||3.55%||3.42%|
|30 yr refi||4.51%||4.37%|
|15 yr refi||3.54%||3.41%|
Today's featured rates: