The stock market closed with a modest gain Tuesday following an afternoon rally as investors breathed a sigh of relief that the Federal Reserve pledged to keep interest rates low “for an extended period” and Standard & Poor’s affirmed Greece’s debt rating.

The S&P 500 Index closed up 8.96 points, or 0.78 percent, at 1,159.47, above the resistance level of 1,150. The Dow Jones Industrial Average closed up 43.76 points, or 0.41 percent, at 10,685.91. The Nasdaq Composite closed up 0.67 percent.

The financial and basic materials sectors performed well, with the Dow Jones U.S. Basic Materials Index closing up 1.72 percent and the Dow Jones U.S. Financials Index closing up 1.26 percent.

At 2:15 pm EST, the members of the Federal Reserve's monetary policy panel announced they would leave the federal funds rate unchanged and stated their expectation of maintaining this low level for an extended period.

As just about everyone expected, there were no material differences between the March 16 FOMC statement and the January 27 statement, said Jeff Rosen, an economist from Briefing.com.

Rosen's models have the federal funds rate remaining at its current level into mid 2011.

However, Thomas Hoenig, the Kansas City Fed President, once again cast a lone dissenting vote.

Citing the risks to longer-run macroeconomic and financial stability and the potential buildup of financial imbalances, Hoenig wanted the Fed to cease expressing the expectation of keeping the federal funds rate low for an extended period.

The Fed, while noting the continued economic recovery, also saw weakness in bank lending and commercial real estate.

The market cheered as Standard & Poor's, the rating agency, affirmed Greece's BBB+ rating. It also took Greece off its credit watch, reducing the probability of an imminent rating cut.

We view the government's fiscal consolidation program as supportive of the ratings at their current level, hence our rating affirmation, said Marko Mrsnik, an analyst from Standard & Poor's.

Greek bonds rallied and the American Depository Receipts of National Bank of Greece (NYSE:NBG) closed up 3.01 percent.

In February, the agency had threatened to cut Greece's debt within a month on Greece's shaky economic outlook and the challenges of implementing its austerity measures.