SHANGHAI, Dec 5 (Reuters) - China's major state-owned banks were busy buying the yuan in currency markets on Tuesday to prevent it from weakening too much, two sources with knowledge of the matter said, with buying intensifying after rating agency Moody's cut China's outlook to negative in the afternoon.

State banks were spotted swapping yuan for U.S. dollars in the onshore swap market and quickly selling those dollars in the spot market to support the yuan throughout the whole trading session, the sources said.

But the banks' dollar selling became very forceful after the Moody's statement, one source said.

China state banks have in the past year often sold dollars to slow the yuan's decline against the U.S. dollar. Markets have often seen the moves as a sign of official attempts to relieve pressure on the currency, though banks could also be trading for their own accounts.

Moody's on Tuesday cut its outlook on China's government credit ratings to negative from stable, citing expectations of lower medium-term economic growth and risks from a deep correction in the country's vast property sector.

With China's economy sputtering and the U.S. dollar surging until recently, the yuan has had a volatile year, having weakened 6.14% to the dollar at one point before giving back much of the losses on recent views that U.S. interest rates have peaked.

The yuan strengthened 2.55% in November, its best month this year, but it is still down 3% year-to-date.

However, some analysts said the impact on the yuan from the Moody's decision will not be sustainable.

"The issues plaguing the property sector are not new," said Khoon Goh, head of Asia research at ANZ.

"The steps taken by the authorities recently should see a bottom soon. The upcoming U.S. data will be more important for the near-term direction of the yuan," Goh said, referring to a spate of government measures to revive the real estate market. (Reporting by Shanghai Newsroom and Tom Westbrook; Editing by Jacqueline Wong and Kim Coghill)