HONOLULU — From a distance, the Chinese warship warned the American destroyer that it was on a “dangerous course” in the South China Sea. Then it raced up alongside, getting perilously close. For a few tense minutes, a collision seemed imminent.

The American vessel, the Decatur, blasted its whistle. The Chinese took no notice. Instead, the crew prepared to throw overboard large, shock-absorbing fenders to protect their ship. They were “trying to push us out of the way,” one of the American sailors said.

Only a sharp starboard turn by the Decatur avoided a disaster in the calm equatorial waters that early morning in September — one that could have badly damaged both vessels, killed members of both crews and thrust two nuclear powers into an international crisis, according to a senior American official, who spoke on condition of anonymity to describe the encounter in detail.

The ships came within 45 yards of each other, marking the closest call yet as the United States Navy contests China’s military buildup in the South China Sea. The Sept. 30 encounter signaled what American commanders fear is a perilous new phase in confrontations in the disputed waterway, which are unfolding without even a Cold War-style agreement on basic rules of conduct aimed at preventing escalation.