(CNN) -- Former U.S. Defense Secretary Robert McNamara, a key architect of the U.S. war in Vietnam under presidents John F. Kennedy and Lyndon Johnson, has died at age 93, according to his family.

Robert McNamara took a lead role in managing the U.S. military commitment in Vietnam.

McNamara was a member of Kennedy's inner circle during the Cuban Missile Crisis in 1962, when the United States and the Soviet Union stood on the brink of nuclear war.

But he became a public lightning rod for his management of the war in Vietnam, overseeing the U.S. military commitment there as it grew from fewer than 1,000 advisers to more than half a million troops.

Though the increasingly unpopular conflict was sometimes dubbed "McNamara's War," he later said both administrations were "terribly wrong" to have pursued military action beyond 1963.

"External military force cannot reconstruct a failed state, and Vietnam, during much of that period, was a failed state politically," he told CNN in a 1996 interview for the "Cold War" documentary series. "We didn't recognize it as such."

A native of San Francisco, McNamara studied economics at the University of California and earned a master's degree in business from Harvard. He was a staff officer in the Army Air Corps during World War II, when he studied the results of American bombing raids on Germany and Japan in search of ways to improve their accuracy and efficiency.

After the war, he joined the Ford Motor Company and became its president in November 1960 -- the first person to lead the company from outside its founding family. A month later, the newly elected Kennedy asked him to become secretary of defense, making him one of the "whiz kids" who joined the young president's administration.

In October 1962, after the discovery of Soviet nuclear missiles in Cuba, McNamara was one of Kennedy's top advisers in the standoff that followed. The United States imposed a naval "quarantine" on Cuba, a Soviet ally, and prepared for possible airstrikes or an invasion. The Soviets withdrew the missiles in exchange for a U.S. guarantee not to invade Cuba, a step that allowed Soviet premier Nikita Kruschev to present the pullback as a success to his own people.

Don't Miss TIME.com: No escape from Vietnam for McNamara

In the 2003 documentary "The Fog of War," McNamara told filmmaker Errol Morris that the experience taught American policymakers to "put ourselves inside their skin and look at us through their eyes." But he added, "In the end, we lucked out. It was luck that prevented nuclear war."

McNamara is credited with using the management techniques he mastered as a corporate executive to streamline the Pentagon, computerizing and smoothing out much of the U.S. military's vast purchasing and personnel system. And in Vietnam, he attempted to use those techniques to measure the progress of the war.

Metrics such as use of "body counts" and scientific solutions such as using the herbicide Agent Orange to defoliate jungles in which communist guerrillas hid became trademarks of the conflict. McNamara made several trips to South Vietnam to study the situation firsthand.

He, Johnson and other U.S. officials portrayed the war as a necessary battle in the Cold War, a proxy struggle to prevent communism from taking control of all of Southeast Asia. But while they saw the conflict as another front in the standoff between the United States and the Soviet Union, which backed communist North Vietnam, McNamara acknowledged later that they underestimated Vietnamese nationalism and opposition to the U.S.-backed government in Saigon.

"The conflict within South Vietnam itself had all of the characteristics of a civil war, and we didn't look upon it as largely a civil war, and we weren't measuring our progress as one would have in what was largely a civil war," he told CNN.

Casualties mounted, as did domestic opposition to the war. In 1965, a Quaker anti-war protester, Norman Morrison, set himself on fire outside McNamara's office window. In 1967, tens of thousands of demonstrators marched on the Pentagon, which was ringed with troops.

By November 1967, McNamara told Johnson that there was "no reasonable way" to end the war quickly, and that the United States needed to reduce its forces in Vietnam and turn the fighting over to the American-backed government in Saigon. By the end of that month, Johnson announced he was replacing McNamara at the Pentagon and moving him to the World Bank. But by March 1968, Johnson had reached virtually the same conclusion as McNamara. He issued a call for peace talks and announced he would not seek re-election.

After leaving the Pentagon in early 1968, McNamara spent 12 years leading the World Bank. He said little publicly about Vietnam until the publication of a 1995 memoir, "In Retrospect."

"You don't know what I know about how inflammatory my words can appear," he told Morris. "A lot of people misunderstand the war, misunderstand me. A lot of people think I'm a son of a bitch."

All About John F. Kennedy • Lyndon Johnson • Robert McNamara • Vietnam