Gold futures closed near $900 an ounce on Friday in New York, making it the highest gain for the contract in 10 weeks as energy costs surged to a record and the dollar weakened, boosting the appeal of the precious metal as a hedge against inflation.

Gold for June delivery climbed to an intraday high of $904.50 on the New York Mercantile Exchange. It closed with a gain of $19.90, or 2.3 percent, at $899.90, a level the contract has not reached since April 23.

Gold is still down 13 percent from a record $1,033.90 an ounce on March 17, when oil and the euro set previous highs.

It's been a commendable turn in gold over the past two days, said Jon Nadler, senior analyst at Kitco Bullion Dealers, in a note to clients.

The precious metal surged $13.50 to close at $880 an ounce on Thursday. June gold ended the week with a gain of 1.6 percent.

The dollar extended losses Friday, despite better-than-expected housing data, after a weak consumer sentiment index reading increased worries over the strength of the U.S. economy.

The dollar index, which tracks the performance of the greenback against other major currencies, fell 0.1 percent to 72.80.

Meanwhile, crude-oil futures reached $127.82 a barrel, the highest ever, as Goldman Sachs raised its second-half-of-the-year forecast for oil prices by 32 percent to $141.

Gold gained 31 percent in 2007 while a 57 percent rise in oil prices contributed to the biggest increase in consumer costs in 17 years.

U.S. consumer sentiment declined further in May, hitting a reading of 59.5 in the preliminary report from Reuters/University of Michigan.

Also on the Nymex, July platinum futures closed up $55.10 to $2,132 an ounce, and ended the week more than 1.4 percent higher. June palladium rose $12.70 to finish at $453.30 an ounce.

July copper futures rallied 9 cents, or 2.4 percent, to close at $3.83 a pound - up almost 3 percent for the week. July silver futures rose 28 cents to close at $16.96 an ounce, and the contract was up just 0.3 percent for the week.