NEW YORK (Reuters) - Oil fell on Friday, erasing early gains as traders dismissed a rate cut by China to focus on a surging dollar and weaker spot prices for U.S. crude as a glut weighed on prompt supplies.

An oil pump is seen in Varadero, Matanzas province, Cuba, during an organized tour by the state-run Cuba-Petroleo (CUPET), October 21, 2015. REUTERS/Enrique de la Osa

A rally in U.S. stocks, however, bolstered risk appetite across financial markets, limiting the downside in oil. [.N]

Brent crude oil was down 21 cents at $47.87 a barrel by 1:27 p.m. EDT, after falling as much as 63 cents earlier.

U.S. West Texas Intermediate (WTI) crude was down 70 cents, or 1.5 percent, at $44.68, after hitting a three-week low at $44.20.

Both Brent and WTI have lost about 5 percent on the week, sliding for a second straight week.

Earlier on Friday, oil prices rose about 1 percent on expectations the Chinese rate cut might prompt the No. 1 energy consumer to import more oil.

Gains, however, faded as the dollar index hit two-month highs, making oil, copper and a host other commodities, less affordable for holders of other currencies.

“It’s terrible price action considering China’s rate cut,” said Scott Shelton, energy broker and commodities specialist for ICAP in Durham, North Carolina. “It shows this is not the solution the market is seeking for crude demand.”

A stubborn global oil glut, partly due to record pumping by the biggest producers in OPEC, has prevented crude prices from staging a meaningful rebound despite a few sharp intermittent rallies since early September.

U.S. crude stockpiles have risen for four straight weeks amid reduced refining activity during the autumn maintenance season. [EIA/S]

The latest reading for the U.S. oil rig count showed drillers idling just one rig this week. [RIG/U]

The rig count indicates whether oil production will rise or fall in the next several months. This week’s decline was the smallest in eight weeks, suggesting the count go up if prices remain where they are or move higher.

In spread play of oil contracts, prompt WTI was at its largest discount in five months to the nearby contract, Reuters data showed, as weak spot prices pushed traders to store more crude for later delivery.

The discount, known as contango, has been widening since Wednesday, reaching a May 19 high of 87 cents.

“We’ve had massive builds. The whole spread curve in WTI is getting weaker, encouraging people to put oil into storage,” said Tariq Zahir, trader in crude oil spreads at Tyche Capital Advisors in Laurel Hollow, New York.