McNamara became a close adviser to Kennedy and advocated the use of a blockade during the Cuban Missile Crisis. Kennedy and McNamara instituted a Cold War defense strategy of flexible response, which anticipated the need for military responses short of massive retaliation. McNamara consolidated intelligence and logistics functions of the Pentagon into two centralized agencies: the Defense Intelligence Agency and the Defense Supply Agency. During the Kennedy administration, McNamara presided over a build-up of US soldiers in South Vietnam. After the 1964 Gulf of Tonkin incident, the number of US soldiers in Vietnam escalated dramatically. McNamara and other US policymakers feared that the fall of South Vietnam to a Communist regime would lead to the fall of other governments in the region.
McNamara grew increasingly skeptical of the efficacy of committing US soldiers to Vietnam. In 1968, McNamara resigned as Secretary of Defense to become President of the World Bank. He remains the longest serving Secretary of Defense, having remained in office over seven years. He served as President of the World Bank until 1981, shifting the focus of the World Bank towards poverty reduction. After retiring, he served as a trustee of several organizations, including the California Institute of Technology and the Brookings Institution.
After business school, McNamara worked a year for the accounting firm Price Waterhouse in San Francisco, then returned to Harvard in August 1940 to teach accounting in the business school and became the highest paid and youngest assistant professor at that time. Following his involvement there in a program to teach analytical approaches used in business to officers of the United States Army Air Forces, he entered the USAAF as a captain in early 1943, serving most of World War II with its
Office of Statistical Control. One of his major responsibilities was the analysis of U.S. bombers' efficiency and effectiveness, especially the B-29 forces commanded by Major GeneralCurtis LeMay in India, China, and the Mariana Islands. McNamara established a statistical control unit for the XX Bomber Command and devised schedules for B-29s doubling as transports for carrying fuel and cargo over The Hump. He left active duty in 1946 with the rank of lieutenant colonel and with a Legion of Merit.