Gold gained on Friday, erasing earlier losses on speculation that higher food and energy prices will spur inflation, while the dollar strengthened against the euro and other major currencies, lowering the investment appeal of the precious metal.

Gold futures for August delivery rose $1.10, or 0.1 percent, to $873.10 an ounce on the Comex division of the New York Mercantile Exchange. Gold hit a record $1,033.90 on March 17. This week, the price has dropped 2.9 percent, the second decline in three weeks.

The U.S. dollar seems to be the main drive in the commodity markets at the moment, weighing mainly on precious metals prices this week, wrote Credit Suisse analysts Tobias Merath and Eliane Tanner in a research note to clients.

Next week, we expect the release of the consumer price index for the Eurozone to influence trading in the precious metals sector.

A government report showed U.S. consumer prices last month rose 0.6 percent, the most since November.

Silver futures for July delivery gained 7.5 cents, or 0.5 percent, to $16.56 an ounce on the Comex. The price advanced 11 percent this year, while gold climbed 4.2 percent.

In Friday's trade on the Nymex, crude futures for July delivery were recently down $1.74 to stand at $135.00 a barrel.