He piloted the Gemini 4 flight in June 1965, during which Edward White made the first US space walk. In March 1969 he commanded Apollo 9 in Earth orbit to test the spacecraft's lunar-landing hardware. McDivitt was selected as an astronaut in 1962. From 1969 he was manager of the Apollo project, and he left NASA in 1972.