Last week, top Hamas leaders traveled to Qatar to select the group's new political leadership, watched by media from around the world.
Delegates from across the Middle East flocked to the area after nearly a year of fighting between Hamas and Israel in Gaza.
Some arrived shaken by the news a few days earlier that the group's former political leader, Ismail Haniyeh, had been killed in an explosion in Tehran blamed on Israel.
Haniyeh, who has overseen the group's negotiators in talks with Israel, has played a key role within Hamas, balancing the militant group's desire to fight Israel with the demands of some to reach a settlement and end the conflict.
It was clear that his position needed to be filled quickly.
At the memorial in Doha, Hamas leaders stood shoulder to shoulder in a huge white tent, carpeted with photos of Ismail Haniyeh and furnished with plush chairs, as hundreds of people gathered to pay tribute to the movement's late leader and his bodyguards.
The scene was more than just a memorial: it marked the end of an era and the beginning of a new, more radical phase.
This wasn't the first time I'd witnessed Hamas' top brass meet to choose a new leader after an unexpected funeral: In 2004, I saw them meet at the group's founder, Sheikh Ahmed Yassin, in his home in Gaza after Israel assassinated him. Less than a month later, Israel killed his successor, Abdel Aziz al-Rantis.
But the behind-the-scenes discussions reflected the seriousness of the crisis and the challenges they face.
Hamas attacked southern Israel on October 7 last year, killing about 1,200 people and forcing 251 hostages back to Gaza. Since then, Israeli retaliation has killed more than 39,600 people and injured tens of thousands more, according to the Hamas-run Ministry of Health. More than half of Gaza's buildings have been damaged or destroyed, forcing almost the entire population to flee. Opposition to Hamas, which has ruled Gaza since 2007, is growing and the organization itself has suffered heavy losses.
Additionally, the killing of Ismail Haniyeh in Tehran on July 31 came as a major shock to the group, as he had always considered Tehran a safe place.
Hamas believes Haniyeh was killed by an anti-personnel missile while browsing his mobile phone. Iran's Revolutionary Guards say a projectile with a 7-kilogram warhead was used. Some Western media have reported that Haniyeh was killed by a bomb planted in his room beforehand.
At Haniyeh's memorial in Doha, a man in his mid-60s with grey hair and a short beard stood in a corner, away from the spotlight.
“Keep an eye on him,” a Hamas media representative told me. Who is he? “He is a man of mystery, Abu Omar Hassan,” he said.
Abu Omar Hassan, or Mohammed Hassan Darwish, is the chairman of Hamas's Supreme Council, its highest advisory body. According to Hamas' charter, he was the front-runner to become the organization's interim chairman until elections scheduled for March next year.
“He is a man of great mission,” he was told.
Once the memorial service was over, the real work of the leadership began: Over two days, the movement's veterans and shadowy figures met in Doha, where Hamas' politburo has been located since 2012, to elect new leaders.
They chose Yahya Sinwar, who has been the group's leader inside the Gaza Strip since 2017. The choice may come as a surprise to many, but anyone who has followed Sinwar's career since Israel released him in a swap deal for captured Israeli soldier Gilad Shalit in 2011 has known that he is likely to one day lead Hamas.
No Hamas political leader is closer to the group's armed wing than his brother Mohammed, who heads Hamas's largest military battalion, and Mohammed Deif, the mysterious Hamas veteran who led the militia for two decades until Israel said he had killed him last month, were his neighbor, friend and classmate. The two grew up together in the sprawling Khan Younis refugee camp in the Gaza Strip.
Nevertheless, appointing Sinwar to this top position in Hamas would be seen by many as madness: Israeli security officials believe he planned and carried out attacks in southern Israel and he is at the top of their wanted list.
“Not everyone in the Hamas leadership agreed with the decision,” a senior Hamas official told me, “some expressed reservations, others wanted someone more moderate, but in the end he won the majority of votes.”
Another senior Hamas official at the meeting said he felt it would be impossible for the movement to elect Abu Omar Hassan, a powerful shadow operative, because he had little public profile and was unknown outside the movement, while the October 7 attacks had made Yahya Sinwar world famous.
“Sinwar has become a trademark since Oct. 7 and enjoys immense popularity in the Arab and Muslim world,” the official said. “He has close ties to the Iran-backed axis of resistance and his appointment in the midst of the war sends a message of defiance to Israel.”
The Axis of Resistance is a network of Iranian-backed militias, whose other components, such as Lebanon-based Hezbollah, also pose a threat to Israel.
Many Arab officials, as well as some Western officials, have urged Hamas not to name Sinwar as its leader because of his involvement in the Oct. 7 attack. Sinwar and the organization he now leads are banned as terrorist organizations by many Western governments.
“One of the reasons we voted for him is because we wanted to honor the mastermind of the attack,” the official said. “October 7 is his day and he is entitled to lead the movement.”
Ten months after the attack, all attempts to reach a ceasefire have so far failed, and the BBC understands that the two main mediators, Qatar and Egypt, are working on new ceasefire proposals.
According to the leaks, the plan was based on persuading Iran not to respond militarily to Haniyeh's assassination on Iranian territory in exchange for Israel ending the war in Gaza and withdrawing its troops from the Philadelphia Corridor.
The Philadelphia Corridor is a buffer zone just 100 meters (330 feet) wide in parts that runs along the Gaza side of the 13-kilometer (8-mile) border with Egypt. Gaza's only other land border is with Israel.
A Palestinian official familiar with the ceasefire negotiations told me in Doha: “Egyptian intelligence has already sent a team to Doha to investigate, and meetings are being held to draw up an action plan to protect the area from Iranian retaliation in exchange for a ceasefire.”
For now, the drums of conflict are only growing louder, with Hamas' most radical figure, Sinwar, set to lead the group for the next five years if he survives the war.