He was speaking at a ceremony marking the centenary of the ruling Communist Party at Tiananmen Square.
He said: “We have never bullied, oppressed, or subjugated the people of any other country, and we never will. By the same token, we will never allow any foreign force to bully, oppress, or subjugate us.”
The Chinese leader was quoted by Reuters as saying: “Anyone who dares try to do that will have their heads bashed bloody against a Great Wall of steel forged by over 1.4 billion Chinese people.”
This comes amid worsening relations between China and the United States and soon after the People’s Liberation Army clashed with Indian troops at the disputed border in the Ladakh region.
Thursday’s ceremony kicked off with a 100-gun salute, and included military aircrafts flying over Tiananmen Square and patriotic songs being played.
Regarding Hong Kong and Macao, Mr Xi said China “will stay true to the letter and spirit of the principle of ‘One Country, Two Systems’”.
He also said: “While protecting China’s sovereignty, security, and development interests, we will ensure social stability in Hong Kong and Macao, and maintain lasting prosperity and stability in the two special administrative regions.”
China has come under mounting criticism for its crackdown in Hong Kong and the national security law that was rolled out in June last year. Pro-democracy newspaper Apple Daily announced its closure after a raid by authorities and asset freeze.
The protests marking the anniversary of the city’s 1997 handover to China were banned as police denied permission for a rally, citing coronavirus restrictions, according to Reuters.
China has also come under fire over its treatment of Uyghurs in Xinjiang. Foreign researchers have said more than 1 million people from predominantly Muslim ethnic minorities are held in detention camps across Xinjiang, but China insists that the camps are for job training purposes.
Mr Xi also committed to “resolving the Taiwan question” in his address on Thursday, saying realising “China’s complete reunification is a historic mission and an unshakable commitment of the Communist Party of China”.
He also said: “We must take resolute action to utterly defeat any attempt toward ‘Taiwan independence’, and work together to create a bright future for national rejuvenation.”
Taiwan is self-governing but claimed by Beijing as a breakaway province. China has warned against any official exchanges with the island as it has stepped up military activities near Taiwan.
Tang Renwu, a professor of public management at Beijing Normal University, told Reuters that Mr Xi’s tough talk was in response to western efforts to “contain and suppress” China.
Mr Xi also said that China’s success hinges on the Party and “any attempt to divide the Party from the Chinese people or to set the people against the Party is bound to fail”.
He added that party must maintain absolute leadership over its military, the People’s Liberation Army. “We will take comprehensive measures to enhance the political loyalty of the armed forces, to strengthen them through reform and technology and the training of competent personnel, and to run them in accordance with the law,” he said.