Oil prices fell for a second day on Wednesday, as much as 1 percent, on unexpected gains in U.S. crude and gasoline stocks in an industry report, while weak U.S. home sales drove equities lower and dampened risk appetite.

Global stock markets fell after a report on Tuesday showed sales of existing U.S. homes dropped unexpectedly in May, raising concern about global economic recovery prospects. Japan's Nikkei average fell 1.7 percent on Wednesday as the positive impact of China's yuan revaluation faded. .T

If the stock market is going down, it is a factor to drive the crude market lower, said Ken Hasegawa, a commodity derivatives manager at brokerage Newedge in Japan. People continue profit taking after the API stock build.

U.S. crude for August delivery tumbled as much as 81 cents to $77.04 and was down 33 cents at $77.52 a barrel by 0630 GMT, after the July contract expired on Tuesday. ICE Brent for August fell 35 cents to $77.69.

Prices of U.S. crude have gained less than 0.5 percent this week after a jump to almost $79 two days ago, following China's weekend decision to make the yuan exchange rate more flexible.

They have recovered about 20 percent from a trough below $65 a barrel a month ago, but are still about $10 lower than an early-May 19-month peak above $87.

Crude stockpiles in the U.S. rose 3.7 million barrels last week, the American Petroleum Institute (API) said on Tuesday, while gasoline supplies climbed 810,000 barrels.

U.S. stockpiles of distillates including heating oil and diesel rose 1.1 million barrels last week, the API said, broadly in line with analyst forecasts.

Traders also awaited government statistics on U.S. oil supplies and demand from the Department of Energy's (DOE) Energy Information Administration due on Wednesday at 1430 GMT.

The market is a bit cautious ahead of the DOE numbers after two weeks of disappointing demand data and bigger-than-expected stock builds, said Stefan Graber, a commodities analyst with Credit Suisse in Singapore.

Investors also awaited Wednesday's conclusion of a two-day U.S. Federal Reserve's Federal Open Market Committee meeting, with a statement due at 1815 GMT, for signs that low interest rates will remain intact.

YUAN EFFECT FADES

The oil market showed little reaction to the publication of the yuan's trading range mid-point on Wednesday, even after the central bank of China set it slightly stronger than Tuesday's close.

Oil prices posted short-lived gains on Tuesday after the bank set the mid-point at its strongest against the dollar since 2005.

It was more a sentiment-driven reaction, Graber of Credit Suisse said.

China is importing a lot of oil and a stronger yuan favors it, but it comes down to whether the economy continues to grow. The revaluation helps address global imbalances and allow for more sustainable growth in the long term.

In the United States, the world's top oil consumer, data showed increasing gasoline demand and a lagging indicator showed a jump in highway travel.

MasterCard's SpendingPulse report said U.S. weekly retail gasoline demand rose 0.4 percent last week versus the previous week. But demand dropped 2.7 percent from a year earlier.

U.S. highway travel jumped 1.2 percent in April from a year earlier, rising 3.1 billion miles to nearly 256 billion miles, the U.S. Transportation Department said on Tuesday.

A U.S. judge blocked the Obama administration's six-month ban on deepwater drilling imposed in the wake of BP Plc's (BP.L) Gulf of Mexico oil spill, but the White House said it would appeal the ruling, issued on a challenge by oil firms involved in offshore drilling.

(Editing by Ed Lane)