The most obvious casualty of Hong Kong’s extraordinary uprising against chief executive, Carrie Lam, and her campaign to tie the city more closely to China, will be the bureaucrat-turned-politician’s own career. If she stays on, it will only be as a lame duck leader.

But the city’s turmoil is also a major challenge to her boss and patron, Chinese president, Xi Jinping.

Lam has been at pains to paint herself as an independent actor in the crisis, and as it unfurled Beijing has publicly doubled down on its expressions of support for her. But neither of those positions are entirely honest.

The show of political power by Hong Kong’s population, and Lam’s humiliating climbdown over a controversial extradition law, are a major headache for Xi, a ruler who has pursued an increasingly nationalist, autocratic agenda since becoming premier of China.

“I think Xi Jinping is probably mad as hell,” said Willy Lam, professor at the Centre for China Studies at the Chinese University of Hong Kong. “(Protestors) have forced Xi to back down, for the first time since he took power seven years ago, from a major policy platform.”

At home the crisis will provide immediate ammunition for his elite enemies inside the Communist party, and eventually perhaps inspiration to a different group of opponents in restive regions including Tibet and western Xinjiang province.

“Sooner or later news will filter through, and again people there will take heart from what Hong Kong people have achieved through a show of unity and coming out to the streets,” Lam said.

In self-ruled Taiwan, which Xi would dearly like see unified with the mainland, the crisis is expected to boost pro-independence president Tsai Ing-wen as she runs for re-election, by providing voters with a dramatic warning of the risks from closer ties with China.

Further afield, the showdown with Hong Kong citizens has given ammunition to critics in the West, at a time when China is hovering on the brink of a trade war with the US and under fierce attack for issues including a network of concentration camps for Uighurs in Xinjiang and its aggressive policy in the South China Sea.

Chinese authorities’ fear of what has been happening in Hong Kong is evidenced in widespread censorship. Many news outlets behind the digital great firewall that blocks China off from the rest of the Internet have avoided it, or briefly attacked foreign meddling in the former British colony. The English-language China Daily carried a report on an anti-US march by Hong Kong parents. It did not mention the protest that organiser’s claim numbered nearly 2 million marching against their own government.

Beijing’s expressions of support for Lam are almost certainly driven only by the calculation that losing a hand-picked leader under public pressure would do Beijing further damage.

Hong Kong chief executive, Carrie Lam, after administering the oath for office in 2017, watched by Xi Jinping. Photograph: Kin Cheung/AP

“The protests in Hong Kong have exacerbated Beijing’s existing challenges. China is already embroiled in a trade war, and protests could strengthen Beijing’s critics in Taiwan as the election approaches,” said Zhixing Zhang, senior east Asia analyst at Stratfor.

“But the fact that Carrie Lam’s political career is at stake forces Beijing to firmly support its own appointed official.”

Lam’s own insistence that the controversial extradition law which lies at the heart of the current crisis was purely her own initiative ring almost as hollow as Beijing’s protestations of confidence.

It is still unclear whether the idea for the law originated in Beijing or Hong Kong, but once on the table, Xi and the ruling Communist party embraced it enthusiastically.

It would have been a useful tool, allowing the government in Beijing to legally pursue critics and fugitives who have set up shop in Hong Kong (it has occasionally kidnapped them in defiance of the law).

It would also have expedited political and legal integration of the two countries, a key goal for China ahead of the 2047 expiry date for Hong Kong autonomy.

Two members of China’s ruling politburo standing committee made unusual public statements in support of the bill, and Lam is reported to have consulted with one of them, Han Zheng, the day before agreeing to suspend it.

Before the current crisis the chief executive had a reputation as a hardworking, competent and sometimes ruthless administrator, which may be why Beijing believed she could shepherd through legislation which would have such a profound impact on every aspect of Hong Kong life.

She has no obvious successor, and as Beijing tries to find one, it will have to confront the fundamental challenge it faces in trying to control Hong Kong, while the city still has freedom of speech and enjoys the rule of law.

“The job of the chief executive is pretty much impossible as they have to answer to two masters with radically different demands,” said Prof Lam.

One is the politburo in Beijing, long a loud and demanding master. But the other is the people of Hong Kong, and now they have found their voice too.