* U.S. diplomat challenged by dispute over security
* Kerry quotes Mandela on achieving the impossible
* Tells Israel that Geneva deal with Iran made it safer
By David Brunnstrom
BEN-GURION AIRPORT, Israel, Dec 6 (Reuters) - U.S. Secretary of State John Kerry closed another Middle East troubleshooting mission on Friday by urging Israel and the Palestinians to follow Nelson Mandela's lead and make peace.
The death on Thursday of Mandela, who fought apartheid in South Africa and became its first black president, was mourned across the globe, including by Israelis and Palestinians - the latter calling him an inspiration for their statehood struggle.
Kerry wants to coax the two sides towards a negotiated accord, and set a nine-month deadline when talks were launched in July. But both sides have indicated they are pessimistic about the outcome.
Before departing from Tel Aviv after a two-day visit to Israel and the Palestinian territories, Kerry quoted Mandela as having said, in the face of challenges, that "it always seems impossible until it is done".
"That example of Nelson Mandela is an example we all need to take to heart as we try to reach a two-state solution," Kerry told reporters, referring to the international vision of Palestinian sovereignty in lands Israel occupied in a 1967 war.
One of those areas, the West Bank and adjoining East Jerusalem, has been extensively settled by Israel, leaving Palestinians worried too little space will be left for them.
The other area, Gaza, was quit by Israel in 2005 and is now ruled by armed Hamas Islamists who spurn coexistence with the Jewish state. Many Israelis question whether U.S.-backed Palestinian President Mahmoud Abbas could commit his Hamas rivals to peacemaking.
On Thursday, Kerry said he presented Israel with "some thoughts" about improving its security under any eventual accord. Neither side detailed these, but Israel has long said it would want to keep a military presence between the West Bank and Jordan, as well as swathes of Jewish settlements.
Abbas's administration opposes major Israeli annexations, deeming the settlements illegal - as do most world powers.
The Palestinians rejected Kerry's security proposals after he raised them with Abbas on Thursday, a Palestinian official told Reuters on condition of anonymity. The Palestinian peace negotiator, Saeb Erekat, denied that account but did not say what Kerry and Abbas had discussed.
After the meeting, Kerry commended Abbas for "his steadfast commitment to stay at the peace negotiations, despite the difficulties that he and the Palestinians have perceived in the process". Kerry said he might return to the region next week.
On Friday, he sounded more upbeat, saying: "I believe we are closer than we have been in years in bringing about the peace and prosperity and security that all the people in this region deserve and have been yearning for."
Kerry's peace mediation was overshadowed, in Israeli eyes, by his role in a Nov. 24 international deal easing sanctions on Iran in return for some curbs on its disputed nuclear programme.
An irate Israeli Prime Minister Benjamin Netanyahu blasted the agreement clinched in Geneva as a "historic mistake" that helped Tehran's limping economy while leaving it with the means to make a nuclear bomb - though the Iranians deny having such designs.
In their three meetings this week, Kerry and Netanyahu took pains to reaffirm their friendship and said Israel and the United States would confer closely on keeping core sanctions against Iran in place while a final nuclear deal is crafted.
Kerry said on Friday that, thanks to the Geneva agreement, "I am personally convinced beyond any reasonable doubt that Israel is safer today ... We have stopped their (Iran's nuclear) programme where it is." (Writing by Dan Williams; Editing by Mark Trevelyan)