SYDNEY, Australia — For years, the graduating classes of Australia’s military training programs studied Dari and Pashto, the languages of distant war-torn lands, eschewing the Bahasa and the Pijin of Asia-Pacific nations close to home.

But as Australian forces wind down their presence in Afghanistan and Iraq, where they have served alongside American troops since the early 2000s, they are renewing their focus on Australia’s island neighbors, which have become a different kind of battleground as China seeks to expand its influence in the region.

Australia has always tried to maintain military forces near home strong enough to deter any potentially hostile power from moving into the South Pacific. But in recent decades, it has not faced such a challenge in the region, and instead has sent its troops again and again to support the United States in faraway conflicts.

Now, with China’s rise, Australia faces a new calculation. On one side is the United States, with whom it has a formal military alliance. On the other is China, a country that is largely seen as crucial to Australia’s economic future. China and the United States increasingly view each other as geopolitical rivals.