It took just a few hours after Hamas’ assault on Israel for Qatar’s prime minister to assemble a team at an undisclosed location in the capital, Doha. As the images emerged of missile attacks, gunmen on motorbikes and hostages seized across the border from Gaza, the Gulf state’s leadership knew what it needed to do.

As the days unfolded from Oct. 7, the round-the-clock operation worked the phone lines — one to Hamas, another to the Israelis — to mediate as retaliatory bombs rained on Gaza, according to a person familiar with the negotiations.

For Qatar, it was a case of cometh the hour, cometh the country. The nation has spent more than a decade trying to position itself as the Middle East’s indispensable go-between, criticized by its neighbors for housing Hamas leaders while maintaining channels to Israel. The time had come to step up.