JERUSALEM — Prodded by President Obama, Israel and Turkey agreed Friday to end a three-year rift caused by a deadly Israeli commando raid on a Turkish ship bound for Gaza, a rapprochement urgently sought by the United States to help contain spillover from the worsening fighting in Syria.