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. In October 1966, he launched Project 100,000, the lowering of army IQ standards which allowed 354,000 additional men to be inducted despite almost all being incapable of functioning in any high stress situation or dangerous environment.
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.