Martin S. Indyk, a diplomat, author and foreign-policy thinker who spent decades trying to solve the riddle of Middle East peace, twice as the United States ambassador to Israel and later as a special envoy for President Barack Obama, died on Thursday at his home in New Fairfield, Conn. He was 73.

The cause was complications of esophageal cancer, his wife, Gahl Hodges Burt, said.

An Australian-bred academic with a quick wit, blunt manner and pro-Israel pedigree, Mr. Indyk cut an unconventional figure in the State Department of the 1990s. But he propelled himself to the heart of America’s efforts to make peace between the Israelis and Palestinians.

In 2013, he shuttled from one side to the other as Mr. Obama’s emissary. Fifteen years earlier, he helped craft an agreement between them at the Wye Plantation in Maryland on behalf of President Bill Clinton.

Mr. Indyk balanced a fervent commitment to Israel, rooted in his time as a graduate student in Jerusalem during the Yom Kippur War in 1973, with an abiding skepticism of Jewish settlements. He saw them as blighting the prospect of a two-state solution, which would allow Israelis and Palestinians to end decades of bloody conflict.

In his final months, he watched in dismay as Hamas fighters attacked Israeli citizens, prompting a ferocious Israeli military retaliation in the Gaza Strip. For Mr. Indyk, the violence carried a tragic echo of what he had referred to in an interview with the journal Foreign Affairs as Israel’s “hubris” before the Yom Kippur War.

“That same hubris has manifested itself again in recent years, even as many people told the Israelis that the situation with the Palestinians was unsustainable,” Mr. Indyk said. “They thought the problem was under control. But now all their assumptions have been blown up, just like they were in 1973.”