Maryland ended its budget year solidly in the black, with a surplus of $344 million, thanks largely to higher-than-expected personal income tax payments, the state’s tax collector reported Thursday.

Comptroller Peter Franchot (D), however, warned lawmakers not to spend the money given economic uncertainty and the specter of additional federal budget cuts thatcould exacerbate a projected gap for Maryland next year.

News of the surplus — which followed word last month of a nearly $545 million budget windfall in Virginia – also touched off a feisty comparison from the governors of the two states.

Asked what the surplus meant for Maryland, Gov. Martin O’Malley (D) said it “depends on whether you are reporting on this side of the Potomac or on the Virginia side,” he said, suggesting that his counterpart, Gov. Robert F. McDonnell (R), had taken too much credit for his state’s good fiscal fortune in the past year.

“On the Virginia side, we would say, ‘We’re ecstatic about the overwhelming budget surplus we currently enjoy, due to good management and tough decisions.’ On this side of the Potomac, we would see we are starting to see signs of a [national] recovery.”

McDonnell spokesman Martin Tucker responded in an e-mail, saying, “Well, on this side of the Potomac, we are ecstatic for our friends in Maryland. Hopefully, this will spare them from Governor O’Malley’s potential plans for another major tax increase,” he said, referring to O’Malley’s comments last month that he remains open to new taxes to help the state fund a backlog of transportation projects and other plans.

The back-and-forth came just days after the two rising stars in their respective parties were lumped together as able chief executives for their preparations and responses to Hurricane Irene. It also came as Maryland and Virginia remain under the threat of a possible credit downgrade because of their close ties to and reliance on federal spending.

Analysts have said that additional budget cuts to the federal workforce likely to be weighed by the Supercommittee on Capitol Hill could imperil either or both of the states’ fiscal conditions. Politically, it would be an embarrassment for either governor to suffer a downgrade before the other. O’Malley and McDonnell this year also lead their parties’ dueling organizations trying to elect Democratic and Republican governors.

Fiscal analysts on Thursday were less concerned about the political debate.

“All you can conclude is that we have more money that we planned, which hopefully means things are a little better than we expected,” said Warren G. Deschenaux, Maryland’s nonpartisan budget analyst, referring to the surplus.

Maryland lawmakers adjourned in April thinking state tax revenue would increase about 5 percent over 2010, giving Maryland $646 million on hand as of the end of June.

It also bet on that revenue, applying $589 million of it to cover shortfalls in the budget year that began in July.

Revenue, however, actually increased about 2.4 percent above projections, or 7.5 percent from 2010, meaning Maryland ended June with just over $990 million in the bank.

Excluding what the state has already committed to spend this year, that would mean about $400 million — instead of $56 million — will be left to apply toward the budget shortfall lawmakers expect for the 2012-13 budget year.

As of April, that shortfall was projected to be more than $1 billion. Federal cuts to Medicare or other programs could add to the gap. And some powerful state senators have ambitious plans for a major increase in transportation spending.

O’Malley used the news of the surplus on Thursday to focus on the upcoming meetings of the Supercommittee, warning that Republicans could do more harm than good with some budget cuts.

“The work of the Supercommittee could kill a nation’s job recovery just as quickly with massive public-sector cuts as you can by driving it into default,” O’Malley said.

“The potential for wrecking the recovery still exists given the volatility in Washington and the determination by the obstructionist minority to slow or halt the recovery.”

Maryland officials also sought to highlight a report released on Thursday by the Center on Budget and Policy Priorities, which showed the state was in the black even though it had increased education spending by more than 10 percent, or $563 per student since 2008. Virginia, the report said, has decreased education spending by 11.5 percent, or $665 per student.