In 1978 McNair was selected as a mission specialist astronaut by the National Aeronautics and Space Administration (NASA). He, along with Guion S. Bluford, Jr., and Frederick Gregory, were the first African Americans selected as astronauts. His first spaceflight was on the STS-41B mission of the space shuttleChallenger (February 3–11, 1984). During that flight astronaut Bruce McCandless became the first person to perform a space walk without being tethered to a spacecraft. McNair operated the shuttle’s robotic arm to move a platform on which an astronaut could stand. This method of placing an astronaut in a specified position using the robotic arm was used on subsequent shuttle missions to repair satellites and assemble the International Space Station.

McNair was assigned to the STS-51L mission of the space shuttle Challenger in January 1985. The primary goal of the mission was to launch the second Tracking and Data Relay Satellite (TDRS-B). It also carried the Spartan Halley spacecraft, a small satellite that McNair, along with mission specialist Judith Resnik, was to release and pick up two days later using Challenger’s robotic arm after Spartan observed Halley’s Comet during its closest approach to the Sun. However, most of the mission’s fame was due to the selection of teacher Christa McAuliffe as a payload specialist. She was to give at least two lessons from space to students around the world. Challenger launched from Cape Canaveral, Florida, on January 28, 1986, but the orbiter disappeared in an explosion 73 seconds after liftoff, at an altitude of 14,000 metres (46,000 feet). McNair and the six other astronauts in the crew did not survive.