Despite recent warnings, Maryland Gov. Martin O’Malley (D) and state finance officials expressed optimism on Tuesday that the state may be spared a credit downgrade in the wake of Standard and Poor’s decision to cut its rating on long-term U.S. debt.

The comments came after S&P issued a release saying it would not consider top ranked state and local governments “directly constrained” by the new federal rating.

Specifically, S&P said the nine states and small fraction of local governments that have maintained long-term AAA status may continue to be ranked one notch above the federal government. Maryland, Virginia and many local governments in the two states have AAA ratings from S&P.

But similar to a warning last month from Moody’s Investors Service, the statement from S&P on Tuesday came with a caveat that could eventually spell trouble for governments closest to Washington:

“We expect that many of these obligors, particularly those with relatively low levels of funding interdependencies with the federal government, or those that, in our view, are likely to manage declines in federal funding without weakening their credit profile, should be able to retain ratings above the U.S. …”

On July 22, Moody’s similarly warned that if the United States lost its AAA rating as a result of a failure to raise the federal debt ceiling that Maryland and Virginia could be downgraded because their economies are so dependent on federal spending. Moody’s, however, has since reaffirmed its AAA rating for U.S. debt.

In another positive development for Maryland and Virginia, neither state was caught up Tuesday in an initial round of downgrades that S&P issued for municipal bonds backed by revenue from federal leases and other federal spending. Governments in California, Florida and Georgia, among others, were affected.

Maryland finance officials said there was also no indication that so-called Build America bonds, which were part of the federal stimulus effort, would be targeted for downgrades. Maryland has sold over $500 million of the bonds in recent years. The federal government subsidizes the interest on the bonds.

The state’s only casualty from the debt crisis so far has been an indefinite delay to plan to refund about $150 million in state debt, a refinancing maneuver that was expected to save Maryland over $5 million in interest payments over the next few years.

“We are pleased to see that Standard & Poor’s is looking at the states individually,” Maryland state Treasurer Nancy Kopp said in a statement. “We believe that Maryland’s prudent fiscal management will be viewed positively by the rating agencies as they review the states.”