Gold prices extended gains for a second day, climbing back above $5,100 as a historical pullback from record highs offered a buying opportunity for investors.