For the third straight time since the economic downturn, the District ended its fiscal year with a budget surplus, reporting $168 million in unforeseen revenue and its highest-ever year-end fund balance of $1.75 billion.

City agencies could barely keep pace with growing budgets. They left $153 million in unspent funds on the table, for a total 2013 budget surplus of $321 million.

“I keep reading it and saying, ‘Wow, this is nice,’ ” said newly installed Chief Financial Officer Jeffrey S. DeWitt, who previously held the top budget job in Phoenix, which was harder hit by the housing bust.

With a building boom and influx of newcomers continuing, half of the District’s unanticipated revenue came from higher-than-estimated property tax revenue, DeWitt said. An additional $62 million came from individual income tax receipts.

Under new government accounting rules, DeWitt said, nearly $79 million had to be set aside to comply with best practices, including how the city counts short-term internal loans.

The remainder of the money is also spoken for, said Mayor Vincent C. Gray (D). The surplus “does not mean we can go on a spending spree,” he said.

To cover payments on the city’s growing debt load after building more than a dozen new schools and revitalizing dozens of parks in recent years, the District must set aside almost $100 million in escrow to cover debt payments, the mayor said.

Legislation and budget measures passed previously by the D.C. Council also direct millions to projects that include cleaning up the Anacostia River.

Gray said $96 million would be carried into the budget cycle beginning this fall and $10 million would go toward a long-term plan to keep enough cash on hand to eventually erase the need for short-term borrowing from Wall Street.

The city has been working toward a goal of keeping 60 days worth of operating expenses on hand. The additional $10 million, however, won’t get the city much further. With overall growth in the city’s budget over the past 12 months, the increase will keep the city about even, with roughly 45 days’ cash on hand.

Gray took credit for the half of the surplus dealing with under-spending by city agencies. He said tighter controls instituted by his administration reversed a trend of agencies routinely exceeding their budgets.

He also announced an effort with council Chairman Phil Mendelson (D) and council member Kenyan R. McDuffie (D-Ward 5) to convince the council to set aside half of all future surpluses for affordable housing.

The District’s current budget is $12.1 billion. Gray is required to submit his next budget April 3, two days after the city’s Democratic primary.