The federal government is in the money again, at least it was for a few weeks.

For June, the U.S. Treasury Department reported a $117 billion surplus on Thursday, thanks to a continued uptick in revenue and a decline in spending.

Another big boon to June's bottom line was a one-time $59 billion payment from Fannie Mae (FNMA), according to the Congressional Budget Office. The government bailed out Fannie during the housing crisis.

June marks the fifth month since October 2011 that the government has recorded a monthly surplus.

There still, however, is a deficit of $510 billion for the first nine months of this fiscal year, which ends Sept. 30.

But that's well below the $904 billion deficit that had accumulated for the same period a year earlier.

In terms of revenue, $287 billion flowed into federal coffers in June, about 10% more than last June.

Individual income tax and payroll tax receipts were up, as were corporate income taxes.

Monthly spending, meanwhile, came in at $170 billion, nearly half the $320 billion in outlays in June 2012.

Related: Spending cuts likely deeper in 2014

One big reason for the drop: The government didn't have to spend anything on Fannie Mae and Freddie Mac (FMCC). In fact, the mortgage giants delivered their biggest slug of dividend payments to the Treasury.

At the same time, spending on defense, student loans, unemployment benefits, and interest on the debt were all down, too.

The June numbers as much as anything reflect the impact of two trend lines this year: A better economy plus fiscal restraint due to the expiration of stimulus measures, the imposition of across-the-board budget cuts, and tax increases on high-income households.

That's why many budget observers now expect that Congress won't be forced to raise the country's debt ceiling before the middle of fall, if not later.

Treasury Secretary Jack Lew, however, has only allowed that the legal borrowing limit won't need to be raised "until after Labor Day."