Ismail Haniyeh, a top Hamas leader who led the Palestinian militant group’s political office from Doha, Qatar, was killed while visiting Iran on Wednesday. He was 62.

Mr. Haniyeh, originally from the Shati refugee camp in northern Gaza, had long played a central role in Hamas, helping lead the group through multiple wars with Israel and through elections. More recently, he managed high-stakes negotiations and diplomacy for Hamas, including the continuing indirect cease-fire talks, mediated by Egypt, Qatar and the United States, with Israel to end the war in Gaza.

He survived one assassination attempt in 2003, when Israel targeted him and his mentor, the spiritual leader and founder of Hamas, Sheik Ahmed Yassin. The Israeli military assassinated Mr. Yassin the next year.

“You don’t have to cry,” Mr. Haniyeh told a crowd gathered outside Al-Shifa Hospital in Gaza City at the time. “You have to be steadfast, and you have to be ready for revenge.”

Mr. Haniyeh was killed on Wednesday in the Iranian capital, Tehran, where he was attending the inauguration of Iran’s new president, Masoud Pezeshkian. He was there along with other senior members of Iran’s “axis of resistance” — allied forces that include Hamas in Gaza, Hezbollah in Lebanon and the Houthis in Yemen.