Paul Keating has warned Australia’s approach to China has been supplanted by the phobias of security agencies and the hysteria of “pious” and “do-gooder” journalists.

In a typically excoriating speech, the former prime minister lambasted Australian security agencies and the media for their anti-China rhetoric, saying they failed to grasp the magnitude of shifting power in the Asia Pacific.

Keating accused the Australian media of “hysteria” and security agencies of undermining the nuance and flexibility of Australian diplomacy.

“My concern is that what passes for the foreign policy of Australia lacks any sense of strategic purpose,” he said in a speech to the Australian’s Strategic Forum event in Sydney.

“The whispered word of ‘communism’ of old is now being replaced by the word ‘China’.

“The reason that we have ministries and cabinets is that a greater and eclectic wisdom can be brought to bear on complex topics... this process is not working in Australia. The subtleties of foreign policy and the elasticity of diplomacy are being supplanted by the phobias of a group of security agencies which are now effectively running the foreign policy of the country.”

Keating said the Australian media had been “up to its ears” in drumming up anti-China hysteria. He singled out the Sydney Morning Herald and the Age, but also criticised the Australian, which was hosting the event Keating spoke at on Monday. He said the media wrongly equated the actions of individual businessmen or universities with the acts of the entire Chinese state. The long-term national interest should guide Australia’s approach to China, Keating said, not “pious”, “do-gooder” journalists who were “fed on leaks” from security agencies and failed to appreciate the magnitude of the shifting dynamics in the region.

“The Australian media has been recreant in its duty to the public in failing to present a balanced picture of the rise and legitimacy and importance of China, preferring instead to traffic in side plays dressed up with the cosmetics of sedition and risk.”

Keating, who championed Australian engagement in the Asia Pacific as prime minister, said the United States had ceded influence and withdrawn from the region as it returned to an “America-first” posture. That was unlikely to change, regardless of who wins the next US presidential election, Keating said. That left Australia in the “deep blue sea” between two great powers.

Keating said Australia must adopt strategic realism in its approach to China and not force upon itself a choice of one great power over the other.

Keating said the prevailing attitude in Australia assumed China’s growth was somehow illegitimate. He countered that China had lifted 20% of humanity out of poverty through its vast economic growth, a feat unprecedented in human history. He argued Australia frequently dealt with states that were not democracies to advance its own national interest, pointing to the west’s alliance with the Soviet Union in the second world war which prevented a German victory.

Keating said no other state, including India, would catch up to China in terms of economic growth, while Donald Trump’s America was retreating within itself, with no appetite for military conflict with China.

The former defence department secretary Dennis Richardson said there was an element of truth to Keating’s criticism of the influence of security agencies, but it was exaggerated. Richardson said he believed the current government was doing “pretty well” in its approach to China, aside from a few missteps.

“Let me be bold. I’ve left government. The fashionable thing to do when you leave government is to piss all over it,” he said.

“I actually think government policy is not too bad [on China].”

Richardson said he was “outrageous” enough to believe that, despite its rhetoric, Labor would do very little differently to the government on China, and challenged his fellow panelist, Labor’s Richard Marles, to outline his party’s grand China plan.

Richardson said he had faith in Australian political leaders to approach China sensibly, saying Australia had not produced a Donald Trump on the right or a Jeremy Corbyn on the left.

“Quite frankly I’d feel a lot more comfortable if Scott Morrison and Anthony Albanese were competing to be the next president of the US than the mob we currently have across there,” he said.

Marles said he believed a more robust approach was needed towards China in the South China Sea. Australia, he said, had benefited greatly from the current global rules-based order, and must act to maintain that status quo.

“I think we need a very robust position on the South China Sea,” he said. “In terms of my advocacy on that it would have been on a more hawkish position from what we have seen from the government.”

The former army chief Peter Leahy, now the head of the University of Canberra’s national security institute, said Australia was losing badly to China in strategic terms, particularly in the South China Sea.

“We are pants down to China on strategy,” Leahy said.

Leahy described the People’s Liberation Army as “formidable”, but also warned against a narrow focus on traditional military capabilities. He said Australia’s national security considerations must incorporate cybersecurity and space warfare.