From missiles flying over Japan to threats of fiery destruction for Guam, North Korea spent much of 2017 provoking its East Asian neighbors—and the United States. While the recent missile tests and threats seem alarming, it’s hardly the first time the U.S. and North Korea have danced on the edge of total war. The secretive nation, currently ruled by dictator Kim Jong-Un, has long engaged in belligerent and sometimes violent behavior to deter other nations from attacking, and to prove the government’s legitimacy to its people. Perhaps no incident is more demonstrative of the risks North Korea is willing to take than the capture of the USS Pueblo that occurred 50 years ago, on January 23, 1968, at the height of the Cold War.

Since the end of the Korean War in 1953, when North Korea and South Korea signed an armistice agreement, the United States has played a direct role in protecting the southern, democratic nation. Throughout the 1950s, as North Korea began rebuilding itself (the U.S. dropped 635,000 tons of explosives on the north during the war, more than the entire amount used over all of the Pacific Theater in World War II), the United States did all that it could to ensure a stable, non-communist government remained in power in South Korea. The U.S. even went so far as to station atomic weapons in the south in 1958, violating the rules of the armistice agreement. The Vietnam War brought an increasing number of American troops to the region, making the United States and South Korea even closer allies.

The growing American involvement in Vietnam led North Korean leaders to believe their country might be next, and the number of violent attacks on the South Korean and American militaries rose accordingly. While only 32 incidents occurred on the heavily fortified DMZ (the border between North and South Korea) in 1964, that number rose to around 500 by 1967. By 1968, the North Korean regime was ready to launch an even more audacious assault—an assassination attempt on South Korean president Park Chung-hee in the presidential mansion, known as the Blue House. A 31-man commando team infiltrated South Korea on January 21 of that year, but were detected before they came close to Park, and all but two men were killed in the ensuing firefight.

Just two days later, North Korean torpedo boats and submarine chasers successfully surrounded and captured the USS Pueblo, a Navy intelligence ship patrolling international waters that had few weapons with which to defend itself. Of the ship’s 83 crew members, one was killed in the attack, while the rest were taken as prisoners. What could have motivated the small, relatively powerless country to commit such a blatant crime?

“There is no evidence that the assassination attempt and the Pueblo incident were related, but the North’s objectives in seizing the ship may have been to detach the United States from the South by forcing the former to negotiate directly with the [North Korean government] to release the prisoners,” writes historian Steven Lee in The Journal of Korean Studies.

In other words, maybe attacking the ship was meant to create a diplomatic divide between the U.S. and South Korea, requiring the United States to open up more direct dialogue with North Korea, which might anger the government in South Korea.

There’s also the theory put forward by the CIA in 1969: that the capture of the Pueblo was a way to ensure the South Korean government couldn’t retaliate against North Korea for the Blue House assassination attempt without causing all-out war.

“There are also some who have suggested that the North Korea failure to assassinate the president [in South Korea] was an embarrassment to the North Korean government, so they captured the ship as a way to distract people,” says Mitchell Lerner, professor of history at Ohio State University and the author of The Pueblo Incident: A Spy Ship and the Failure of American Foreign Policy. “I don’t actually think there’s much to that. They were very different operations.”

In Lerner’s opinion, the main motivation for capturing the Pueblo was domestic propaganda. “This was a way to demonstrate their strength, their power, that they had forced the might United States to capitulate,” Lerner says. At the time of its capture, the North Koreans didn’t know the ship carried any surveillance technology or sensitive documents. From outside appearances, it seemed to be no more than an old cargo carrier—an easy target.

Condemnation of the attack came rapidly from the United Nations and all of America’s allies—and, secretly, in the following years, from Communist powers like the Soviet Union and China. Though President Lyndon B. Johnson didn’t want to launch a second war in Asia, he seriously considered military retaliation. In a deployment operation named “Combat Fox,” Johnson sent B-52 bombers and aerial refueling craft to Okinawa and Guam, 200 F-4 fighter jets to the Korean peninsula, and three nuclear aircraft carriers to the sea between Japan and the Korea, Lee writes.

Meanwhile, Secretary of Defense Robert McNamara told Johnson, “The great danger that we must avoid is that the Soviets and the North Vietnamese will interpret something that we do as a sign of weakness.”

But the cost of war would’ve been far too high, and “military action designed to extricate the [imprisoned] sailors would likely only see them killed,” Lee writes. Plus, there was the Vietnam War to consider. South Korea was one of America’s best allies in the war, contributing tens of thousands of soldiers to the fight.

“In the wake of the Blue House raid and the Pueblo incident, they were starting to make noise that they might withdraw their forces [from Vietnam] and launch an attack on North Korea, and the United States certainly didn’t want that,” Lerner says.

So the U.S. began providing even more domestic assistance to South Korea in return for their continued aid in Vietnam, while also negotiating with North Korea for the release of the 82 men from the Pueblo, who were regularly tortured throughout their detention and eventually forced to sign documents admitting to unlawful spying.

Negotiations moved slowly and were largely unproductive. It wasn’t until December 23, 1968—a full 11 months since the Pueblo was captured—that chief negotiator Major General Gilbert Woodward signed a document apologizing for illegal spying and promising never to do so again, while at the same time verbally repudiating the apology. The 82 crewmen were then released, though the Pueblo stayed in North Korean custody, where it remains to this day.

“In every crisis recorded in the archives, it was U.S. restraint that prevented war,” said Van Jackson, political scientist at Victoria University of Wellington, by email. “We found out later—through conversations that North Korean officials had with Soviet counterparts—that North Korea was poised to retaliate against our retaliation had we chosen to do so.”

Apart from the value of restraint and diplomacy, Lerner suggests policymakers take another lesson from the Pueblo incident: recognition of North Korea’s independence.

“China is not the answer to the North Korea problem,” Lerner says. “In 1968, American policymakers never really accepted the idea that North Korea might have acted alone and for its own internal reasons. Instead they looked for larger conspiracies, whether it was the Soviets or the Chinese. For the last few decades, American politicians have talked about how the answer to North Korea is China, and China can bring them under control. The reality is the relationship between China and North Korea is not nearly as simple as American policymakers seem to think.”

But perhaps most important is the fact that starting a war today would likely result in millions of deaths, and could turn into a global conflict. “The lesson we have to take above all else is patience,” Lerner says.