NEW YORK (Reuters) - U.S. stocks and oil prices gained on Friday on a rise in U.S. consumer sentiment to a more than five-year high, outweighing gloom that the "fiscal cliff" in the United States and Europe's economic woes may lead to a world recession.
Stocks later trimmed their gains after President Barack Obama said any deal with Congress to avert a fiscal crisis must come with higher taxes on the wealthiest Americans.
U.S. Treasury bonds cut losses to trade almost flat on Obama's remarks, in which the newly re-elected president invited congressional leaders to the White House next week to start negotiating.
A 3.5 percent gain in gold prices this week was bullion's biggest weekly rise since late August and reflected a hedge against economic uncertainty.
The so-called fiscal cliff, aimed at cutting the federal budget deficit, could take an estimated $600 billion out of the economy in automatic spending cuts and tax hikes, severely hindering economic growth.
"Clearly taxes are going up and that is something the market doesn't like. There is concern the economy continues to weaken, and there is not much left in the tank in terms of making corporate profitability better," said Stephen Massocca, managing director at Wedbush Morgan in San Francisco.
The surprisingly strong sentiment survey showed American consumers felt more optimistic about employment prospects and the economic outlook, according to a Thomson Reuters/University of Michigan index, easing the gloom from Europe.
MSCI's world equity index slipped almost 2.2 percent this week, the steepest weekly decline since the start of June. The index fell 0.1 percent to 323.27.
The Dow Jones industrial average closed up 4.07 points, or 0.03 percent, at 12,815.39. The Standard & Poor's 500 Index rose 2.34 points, or 0.17 percent, at 1,379.85. The Nasdaq Composite Index gained 9.29 points, or 0.32 percent, at 2,904.87.
European shares provisionally ended flat, paring losses on the U.S. data, which included a government report that wholesale inventories rose in September by the most in nine months. Inventories are a key element in the government's measure of economic growth.
The FTSE Eurofirst 300 index of top European shares closed down 0.05 percent at 1,097.18 after trading higher briefly before the market's close.
Falling industrial output in France, Italy and Sweden and a warning from a German ministry that Europe's largest economy was expected to slow further rattled investors.
Also weighing on investors was news that euro zone finance ministers are unlikely to release a new tranche of loans to Greece on Monday because there is no agreement on how to make its debt sustainable.
"It's the core Europe now, not just the peripheral Europe, that may be sliding into a recession," said Boris Schlossberg, managing director of FX Strategy at BK Asset Management in New York. "If that happens, then China will lose its export market and the whole global economy will begin to contract.
"The market is very afraid that Europe could drag the whole global economy down."
Oil pushed higher in choppy trading, lifted by the improved U.S. consumer sentiment and Chinese data indicating a strengthening economy.
U.S. crude futures gained 98 cents to settle at $86.07 a barrel, while Brent futures settled $2.15 higher at $109.40 a barrel.
The euro dropped to a two-month low against the U.S. dollar and could extend losses as fears mount that the euro zone's debt crisis and deteriorating economic conditions could drag on global economic growth.
The euro was down 0.27 percent at $1.2711 and was seen vulnerable to further losses. The dollar index rose 0.31 percent to 81.041.
Gold hit a three-week high of $1,738.66 an ounce before pulling back. Spot gold prices rose $1.47 to $1,731.40.
U.S. COMEX gold futures for December settled up $4.90 at $1,730.90 an ounce.
Prices of safe-haven U.S. Treasuries slipped as stock gains sparked by improved consumer sentiment whetted investors' appetite for riskier assets.
The benchmark U.S. Treasury 10-year note was flat in price to yield 1.6165 percent.
Reporting by Herbert Lash; Additional reporting by Richard Hubbard and Marc Jones in London; Ryan Vlastelica, Wanfeng Zhou and Chuck Mikolajczak in New York; Editing by Dan Grebler and Leslie Adler