Had the weapons been used, it would have added to the horrors of one of the most tumultuous and violent years in modern American history. Johnson announced weeks later that he would not run for re-election. The Rev. Dr. Martin Luther King Jr. and Robert F. Kennedy were assassinated shortly thereafter.

The story of how close the United States came to reaching for nuclear weapons in Vietnam, 23 years after the atomic bombings of Hiroshima and Nagasaki forced Japan to surrender, is contained in “Presidents of War,” a coming book by Michael Beschloss, the presidential historian.

“Johnson certainly made serious mistakes in waging the Vietnam War,” said Mr. Beschloss, who found the documents during his research for the book. “But we have to thank him for making sure that there was no chance in early 1968 of that tragic conflict going nuclear.”

The new documents — some of which were quietly declassified two years ago — suggest it was moving in that direction.

With the Khe Sanh battle on the horizon, Johnson pressed his commanders to make sure the United States did not suffer an embarrassing defeat — one that would have proved to be a political disaster and a personal humiliation.

The North Vietnamese forces were using everything they had against two regiments of United States Marines and a comparatively small number of South Vietnamese troops.

While publicly expressing confidence in the outcome of the battle at Khe Sanh, General Westmoreland was also privately organizing a group to meet in Okinawa to plan how to move nuclear weapons into the South — and how they might be used against the North Vietnamese forces.