Sir Keir’s speech in the City of London rejected the “isolationism” put forward by opponents of the Chinese government, notably former Conservative leader Iain Duncan Smith, who say the state should be treated as an enemy.

However, failing to navigate a relationship with China would be “a dereliction of duty”, the prime minister said, when China is a “defining force in technology, trade and global governance”.

Building a careful relationship would instead bolster the UK’s place as a leader on the international stage and help secure UK national interests, he said, while still recognising the “reality” that China “poses national security threats”.

“Instead, for years we have blown hot and cold,” he said. “We had the golden age, which then flipped to an Ice Age. We reject that binary choice.

“So our response will not be driven by fear, nor softened by illusion. It will be grounded in strength, clarity and sober realism.”

Those security threats were clearly outlined earlier this month, when security services took the unusual step of issuing a warning that specifically identified two LinkedIn profiles set up with the names Amanda Qiu and Shirly Shen.

The alert explained the profiles were being used on behalf of the Chinese Ministry of State Security (MSS), acting as “civilian recruitment headhunters” to target individuals working in British politics “at scale”, including economists and think tank employees as well as people in Parliament.

A Chinese Embassy spokesperson denied the accusations of espionage and said they were “pure fabrication” that were “undermining China-UK relations”.

Fears of espionage have also been raised around a huge new Chinese embassy, which would be the biggest in Europe, sitting on a site at Royal Mint Court, which is close to the City of London and fibre optic cables carrying vast quantities of highly sensitive data.

Housing Secretary Steve Reed has the final say and is expected to give the green light to the plans, following consultation with MI5 and MI6, in a decision opposed by Conservatives and Liberal Democrats.

At the speech in London’s Guildhall, Sir Keir insisted there would not be any “trade-off” between security and economic access with China, appearing to rule out trade on areas of defence, AI or critical national infrastructure.

“Protecting our security is non-negotiable – our first duty,” he said.

“But by taking tough steps to keep us secure, we enable ourselves to cooperate in other areas.”

These areas would include financial and professional services, creative industries, pharmaceuticals and luxury goods, he said, adding they were: “Great British success stories – the export opportunities are huge and we will back you to seize them.”