RICHMOND — Virginia banked a revenue surplus of roughly $552 million when the state’s fiscal year ended June 30, Gov. Ralph Northam (D) said Thursday.

The state brought in 6.3 percent more in tax revenue for 2018 than the year before, significantly more than the 3.4 percent increase that officials had anticipated. The figures are preliminary and will likely be revised in coming weeks, they said.

Payroll and sales tax collections were up, signaling a growing economy. But they accounted for less than half of the overall surplus. The biggest driver of the increase was nonwithholding income tax collections, a volatile type of revenue that involves people making estimated payments on capital gains, dividends, partnerships and interest income.

That surge might have come from wealthy taxpayers rushing to get ahead of changes to federal tax law that go into effect this year, state officials said. With the state’s unemployment rate down to 3.4 percent, though, Northam touted the revenue bump as evidence of economic strength.

“I am particularly encouraged by the strong growth in payroll withholding, which is a sign that our investments in building a stronger economy and a more prepared workforce are paying off for Virginians in every corner of the Commonwealth,” Northam said in a statement.

The Republican speaker of the House of Delegates spread the credit to GOP leaders in Washington. “Federal tax cuts passed by Congress and signed by the President, a resurgence in defense spending, and the Republican-led General Assembly’s pro-business policies are leading to strong economic growth in the Commonwealth,” Kirk Cox (Colonial Heights) said in a news release.

Almost all of the extra cash will go into the state’s short-term and long-term rainy-day funds — shoring up Virginia’s AAA bond rating.

The General Assembly struggled to complete a state budget this year, caught up in a fight over whether to accept federal dollars to expand Medicaid under the Affordable Care Act. At the center of that battle was some $400 million in state money that the federal dollars would free up for other uses.

Republicans in the state Senate who opposed Medicaid expansion pointed out that the state was headed for a surplus anyway and wouldn’t need the federal help to meet other budgetary goals, such as giving raises to teachers and law enforcement.

But other lawmakers cautioned that this year’s strong numbers could be a one-time phenomenon and that it wouldn’t make sense to build a budget around them. Much of the increased revenue is from estimated payments, and refunds to those taxpayers could change the results.

So when the two-year, $115 billion spending plan was finally adopted in May, the legislature included the federal money for Medicaid expansion and committed most of the increased tax revenue to the state’s rainy-day funds.

“This significant surplus will substantially increase the Commonwealth’s cash reserves in order to protect taxpayers against a future economic downturn,” Northam said Thursday.

Virginia’s economy has been slow to recover from the 2008 recession because the state is so closely tied to federal spending, which has lagged. And the recovery has been patchy — Northern Virginia and Richmond have been strong, while Hampton Roads is flat and rural areas to the south and west are suffering as coal and textile industries have collapsed.

Thursday’s numbers were not uniformly positive. The sales tax increase was only a tenth of a percent greater than expected. Payroll taxes were up 5.4 percent, greater than a projected 3.5 percent. But about half of the extra increase was because the Fourth of July holiday fell on a Wednesday “and business tax payers submit[ted] payments early,” the governor’s office said.

Corporate income tax collections were lower than expected, increasing 4.2 percent over last year instead of a projected 5.7 percent increase.

Laura Vozzella contributed to this report.