Gold gained for the first time in four sessions after Israel tested its missile-defense system, fueling concern that tensions in the Middle East will escalate and boosting the appeal of haven assets.