Gold futures rose to the highest level in almost three weeks on Monday as surging energy costs boosted demand for the precious metal as a hedge against inflation.

Gold for June delivery closed $5.90 higher at $905.80 an ounce on the Comex division of the New York Mercantile Exchange. Earlier, the price reached $914.20, the highest for a most-active contract since April 23.

On Friday, gold closed with a gain of $19.90, or 2.3 percent, at $899.90 an ounce. The contract was up 1.6 percent for the week.

Gold will fall to $835 in the next 12 months as the dollar rebounds, Goldman Sachs Group Inc. said in a report released on May 16.

Crude-oil futures approached the record high from May 16 before erasing gains. Crude-oil futures climbed as high as $127.77 a barrel in electronic trading before retreating to $126.30 on the New York Mercantile Exchange.

The dollar recovered from a two-week low and rallied as much as 0.5 percent against a weighted basket of the euro, yen and four other major currencies. Earlier, the index dropped as much as 0.4 percent. The gauge is up 3.3 percent to 73.08 from a record 70.698 on March 17.

The dollar index, which tracks the performance of the greenback against other major currencies, was at 73.084, up from 72.799 in late North American trading Friday.

Also on the Nymex, July silver futures rose 6.8 cents, or 0.4 percent, to $17.028 an ounce. The price has advanced 14 percent this year, while gold has climbed 8.1 percent.

July copper fell 5 cents to close at $3.78 a pound. July platinum futures rallied $26.20 to end at $2,158.20 an ounce while June palladium closed down by $1.95 to $451.35 an ounce.