When Chinese President Xi Jinping called for a ceasefire and an end to the “collective punishment” of the people of Gaza on the sidelines of the BRICS summit this week, his comments added to a steady drumbeat of criticism of Israel since the start of its war with Hamas.

“It is necessary to ensure the safe and unimpeded passage of humanitarian assistance and stop the collective punishment against the people of Gaza through forced eviction, as well as turning off water, electricity and oil,” Xi said on Tuesday via video link at the summit hosted by South African President Cyril Ramaphosa.

China’s initial response to the conflict was cautious and equivocal in apportioning blame.

Beijing waited until a day after Hamas’s October 7 attacks on Israel to call on the “relevant parties” to end hostilities and stress the need for a two-state solution, and did not condemn the Palestinian armed group or mention it by name.

But within a week of the attack, Chinese diplomats began to call Israel’s bombardment of Gaza a form of collective punishment and insist that the country’s right to self-defence should be guided by international law and not come at the expense of innocent civilians.

Since then, Beijing has called for multilateral and peaceful solutions to the conflict of the kind promoted by the United Nations, where Beijing took the helm of the powerful Security Council earlier this month.

China, which has expressed its desire to be a peace broker in the Middle East, this week welcomed the announcement of the four-day truce between Israel and Hamas that took effect on Friday.

Chinese state media was quick to claim credit on Beijing’s behalf, with the state-run Global Times saying the ceasefire could be attributed to multiple factors including “the latest UN Security Council resolution adopted under China’s rotating presidency” and “the strong voice of the Global South”.

China’s stance on the war is a matter of contention among analysts.

While some see a clear pro-Palestinian through-line in Beijing’s foreign policy, others argue it is simply mirroring a global balance of opinion that is increasingly critical of Israel’s bombing campaign.

Before the war, China maintained friendly relations with both Israel and the Palestinians.

During the Mao Zedong era in the 1960s, Beijing viewed the Palestinian cause as part of the global campaign against imperialism and armed factions of the Palestinian Liberation Organization.

China now buys large quantities of oil from Iran, one of Hamas’s main patrons, and key broker Qatar, as well as other Gulf states such as Saudi Arabia.

Under Xi, China’s comments about the war have been fairly consistent with past statements about Gaza made in 2008, 2014, and 2021, according to The China Project, typically calling for an end to violence and a mediated resolution.

In 2008, for instance, former top diplomat Qin Gang called for an end to “actions that cause injuries and deaths to ordinary people” and for all parties to “exercise maximum restraint and to settle differences through dialogue”.

Still, there have been noticeable shifts in Beijing’s rhetoric towards statements that are more critical of Israel, said Benjamin Ho Tze Ern, an assistant professor at the S Rajaratnam School of International Studies’ (RSIS) China programme, such as its statement that the country had “gone beyond self-defence”.

Ahmed Aboudouh, an associate fellow at Chatham House’s Middle East and North Africa Programme, said in a recent commentary that China was clearly signalling its support of the Palestinian side.

“The rhetoric from Beijing is carefully designed to focus on the broader context, such as implementing the two-state solution, addressing humanitarian issues and preventing the conflict from turning into a regional one,” Aboudouh wrote in a commentary on Chatham House’s website in October.

“It has refrained from describing the Hamas incursion into Israel as a terrorist attack but has called Israel’s retaliation ‘collective punishment’ of Palestinian civilians – signalling its opposition to an Israeli ground invasion of Gaza.”

Manoj Kewalramani, a foreign policy analyst for the Bangalore-based Takshashila institution, said China’s statements during the most recent conflict have shown a distinct pro-Palestine bent.

“Since [October 8], Beijing has been critical of Israel’s actions, warning about violations of humanitarian law and against ‘collective punishment. It has consistently called for a ceasefire, the need to avoid a spill-over of the conflict and the need to host a broader peace conference with a clear roadmap for a two-state solution,” Kewalramani said.

China has also not shied away from positively expressing its support for Palestinians.

Earlier this week, Chinese Foreign Minister Wang Yi told a group of visiting diplomats from the Organisation of Islamic Cooperation, Palestine, Saudi Arabia, Egypt, Jordan and Indonesia that China was a “good friend and brother of Arab and Muslim countries” and a firm supporter “of the cause of the Palestinian people”.

However, Hongda Fan, a professor at the Middle East Studies Institute of Shanghai International Studies University, rejected the notion that Beijing is “biased against Israel”.

Fan said Beijing’s position simply reflects the balance of global public opinion amid mounting civilian casualties in Gaza, where at least 14,532 have been killed, according to Palestinian health authorities.

“The ‘two-state solution’ has not yet gained universal acceptance in Israel. In addition, China’s relations with Arab countries and Iran have been developing relatively smoothly in recent years. These factors combine to make China appear to be siding with Palestine. Not really,” he said.

“And overall, international public opinion is becoming increasingly unfavourable to Israel, which also shows that China’s position is not biased against Israel,” he said.

RISIS’s Ho said the conflict has helped China score points against the United States, its main competitor, which is Israel’s biggest ally and backer.

As US officials travelled through the region in October and November, Chinese diplomats did the same, visiting countries including Qatar, Iran, Egypt and Saudi Arabia, while also meeting with Israeli representatives in Beijing.

“Since US policies seem to be more aligned with Israel, it is not surprising that China tends to align with Palestine, which is also viewed as the underdog,” Ho told Al Jazeera.

“This reflects China’s ‘underdog diplomacy’ and that it wants to be seen as on the side – or at least, demonstrating support for – states that are being ostracised by the West.”