Secretary of State George Shultz left for home having given New Zealand's new Labour government time to decide whether it wants to retain its defense alliance with the United States.
In two days of talks here, Mr. Shultz laid it firmly on the line: New Zealand could not stay in the ANZUS security pact with Australia and the US if it banned US nuclear-armed and nuclear-powered ships from its ports.
But he left expressing optimism that the new government under David Lange, elected Saturday but not yet sworn in as prime minister, would change its campaign policy of banning the ships and remain in ANZUS. US officials said no ship visits were planned in the next six months.
''We have some problems here and we'll work at them,'' Shultz told a press conference. He said the United States and New Zealand had had a ''warm and deep relationship over a long time and it will continue that way.''
After talks with Shultz, Mr. Lange told journalists: ''There will be a continuing association and dialogue and we value that. We have a pledge based on our history, on economic reality, and in security terms, to have the closest possible relationship with the United States.''
Speaking after the annual two-day ANZUS pact meeting, Shultz made it clear that the US wanted New Zealand to remain in the alliance - an alliance for peace which he said had stood the test of changes in government in all three countries over the last 33 years.
But he stressed the nuclear-ship visits were vital: ''If you shy away from nuclear weapons, you are shying away from the weapon that has provided the main deterrent against the Soviet Union's very large nuclear arsenal and kept the peace.''
Lange's comments reflected his own firm, pro-American position in the center of his party. But he will have a major battle with the left wing if he is to change the antinuclear policy the party adopted last year.
His problem is compounded by a strong antinuclear feeling throughout the country, reflected in Saturday's election, when 64 percent of voters supported parties favoring a nuclear-free New Zealand.
New Zealand was represented at the ANZUS meeting by the lame-duck National Party government of Sir Robert Muldoon, which fully backs ANZUS but was heavily defeated on Saturday.
The communique reaffirmed US ship visits as ''essential to the continuing effectiveness of the alliance.''
Shultz said later: ''What kind of an alliance is it if the military forces of the countries involved are not allowed to be in contact with each other?''
Adm. William J. Crowe, US commander in chief of Pacific forces, confirmed that the Lange government would have time to assess its policy, saying no ship visits were planned for six months.
Shultz rejected another plank of Labour's campaign policy which called for a ''review'' of ANZUS, saying ''I don't think there's anything really to renegotiate.''
But, noting that Australia had demanded a review of the treaty last year following the election of a Labour government there, he said: ''I think a thorough examination will lead people to the same conclusion - that it is of tremendous benefit to all the countries involved.''
The Lange administration has more pressing matters on its hands, including a constitutional crisis over Sir Robert's failure to take advice from the Treasury over a run on the New Zealand dollar. Foreign exchange transactions have been suspended since Sunday night pending a Labour decision on whether to devalue.