WELLINGTON, New Zealand When it became clear that China was pressing ahead with its encroachment on Hong Kong, the "Five Eyes" countries discussed a joint statement condemning the rapid erosion of freedoms in a city that was supposed to have those safeguards until 2047.

But when the statement came out, only four of the countries — the United States, Britain, Canada and Australia — had signed it. New Zealand released its own, separate statement, worded almost identically.

It was a sign of how, under Prime Minister Jacinda Ardern, New Zealand is recalibrating its dealings with both Beijing and Washington — and walking a tightrope.

After almost a decade of becoming ever more economically dependent on China, the Pacific nation of 5 million is seeking an elusive middle ground where it can be critical when its values demand, but without hurting its economic interests. This is harder still as China’s authoritarian leadership shows increased willingness to mete out economic punishment and take political hostages, sometimes over the slightest perceived criticism.

“China has changed under Xi Jinping, and we need to adjust the way we respond and work with China,” said Rodney Jones, a New Zealand economist who worked in Beijing for years. “It’s become about common interests and trade rather than any kind of friendship.”

Like many Western democracies, New Zealand has come to the realization that China’s economic rise has not, as many hoped, led to political liberalization. Beijing’s moves on Hong Kong and its human rights abuses in the Xinjiang region, both driven by Xi, are evidence of that.

New Zealand was the first developed country to sign a free-trade agreement with China, inking a deal in 2008 that helped it dodge the brunt of the financial crisis.

Since then, and particularly during the nine years led by a center-right national government, most of them under former investment banker John Key, New Zealand has enjoyed booming trade with the Asian giant. Its goods exports to China’s ­1.4 billion-strong consumer market quadrupled; China now buys one-third of New Zealand’s dairy and seafood exports, almost half its meat and wool, and almost 60 percent of its logs and timber.

Migration to New Zealand surged, with students flocking to universities and rich Chinese snapping up investor visas. Before the novel coronavirus hit, China was forecast to overtake Australia as New Zealand’s largest source of tourists within the next three years.

This period also came with a growing sense, especially among big exporters, that New Zealand could not say anything negative against China for fear of upsetting the apple — and milk and lamb and kiwi fruit — cart. Under Key, New Zealand became the first Western nation to sign on to Beijing’s Asian Infrastructure Investment Bank and the Belt and Road Initiative, two of Xi’s signature policies.

But a reappraisal has occurred in the past three years as Xi has led China back toward authoritarianism, and after New Zealanders elected Ardern’s center-left coalition in 2017.

“I feel things are rebalancing a bit from the previous nine years, which were reasonably uncritical,” said Helen Clark, who was prime minister when New Zealand signed the trade deal with China and has a close relationship with Ardern.

In tweaking New Zealand’s position, however, Ardern is seeking to be less confrontational than the Trump administration and Australia’s government — which is viewed here as “deputy sheriff” to the United States — even while often making the same points. Ardern’s office declined requests for an interview.

New Zealand has also felt less beholden to the United States under President Trump, who on his third day in office withdrew from the Trans-Pacific Partnership, a 12-nation bloc championed by New Zealand. This was not only a blow in economic terms but was also seen as a sign of Trump’s lack of interest in the region.

“There’s been no attempt by the U.S. to build a coalition of like-minded countries,” said Jones, the economist.

In private conversations, U.S. officials say they understand the China predicament for a small, export-oriented country like New Zealand. But it is also true that Beijing has sought to drive wedges into traditional alliances to divide and conquer.

Now Ardern’s government is trying to walk a fine line.

Since the Key years, New Zealand has become “cleareyed” about how China functions as a state, said one government insider who spoke on the condition of anonymity to discuss internal conversations.

Ardern raised the issue of human rights abuses in Xinjiang directly with Xi during her visit to Beijing last year — but behind closed doors. There have been statements on the increasing repression in Hong Kong, and calls for Taiwan to be readmitted to the World Health Assembly, even as Ardern said New Zealand still recognized that Beijing had a “One China” policy.

Her government has also framed the decision over whether to allow Huawei gear in New Zealand’s 5G network as country-agnostic and one to be made by bureaucrats, not politicians.

And there has been a shift in the way New Zealand’s government talks about military issues, including Beijing’s military buildup in disputed waters. David Capie, director of the Center for Strategic Studies at Victoria University, referred to a 2018 white paper that used much more forthright language than previously.

“The Strategic Defense Policy Statement broke new language in the way we talked about China in the South China Sea,” he said. “It was not hairy-chested Pompeo-style speech, but it’s all there,” he said, referring to U.S. Secretary of State Mike Pompeo.

While criticizing China in some areas, New Zealand has made sure to find areas where they can cooperate — on climate change and at the World Trade Organization, for instance — to “provide some ballast in the relationship,” the government insider said.

“We don’t want to be seen as supine because of economic dependency,” he said. He characterized New Zealand’s China policy as “engage but . . . ”

But Key said it was because of the strong economic relationship that the diplomatic one could evolve. “Now we are more interlinked by trade, so you would hope all parties can find a more mature and better way of dealing with issues,” he said in an interview.

In talking about how New Zealand can make difficult but necessary decisions, analysts and officials here hark back to New Zealand’s 1984 decision to ban ­nuclear-powered ships from its waters.

This effectively barred U.S. Navy vessels and led New Zealand to be frozen out of ANZUS, the military alliance with Australia and the United States. But to this day, New Zealand’s nuclear-free policy has overwhelming support here, despite the costs.

“We’ve been known as a country that speaks its own mind,” Clark said in an interview. “New Zealand foreign policy is at its best when people think, ‘The Kiwis are saying that they’ve figured that out themselves, they’re not acting on behalf of anyone else.’ ”

Tony Browne, New Zealand’s ambassador to Beijing until 2009, said the nuclear-free decision gave the country “a lot of latitude to take positions without the constraints of an alliance relationship” — and could be applied to China today.

But the challenge now is to chart a path without suffering the same blowback as countries such as Australia and Canada.

After Australia called for an inquiry into the origins of the coronavirus, China blocked its barley and beef exports. Ardern waited until a coalition of dozens of countries was ready to seek an inquiry before backing one, and said New Zealand was not interested in a “witch hunt.”

After Canada arrested Huawei chief financial officer Meng Wanzhou at the request of the U.S. Justice Department, China curbed imports of Canadian canola and pork and detained two of the country’s citizens.

Businesses here are uneasy about the shift to a more nuanced approach toward China. As the coronavirus raged, a group of ­primary-goods exporters wrote to Ardern, urging her not to allow any damage to the relationship.

New Zealand has to deal with China “as it presents in the world today,” even when that doesn’t match New Zealand’s hopes for China, said Stephen Jacobi, head of the New Zealand International Business Forum, which represents some of the nation’s largest primary exporters, including the milk giant Fonterra and fruit, seafood and meat producers.

“New Zealand has a lot at stake in this relationship,” Jacobi said. “We have no domestic market to rely on. We cannot replace Chinese consumption anywhere else in the world.”

But others, such as Browne, the former ambassador to China, say New Zealand can’t afford to ignore its values. “The navigation up to this point has been very astute,” he said, “but the middle road is a hard one to follow.”