Richard Gordon, who undertook what became a harrowing and abortive spacewalk in a 1966 NASA mission, then orbited the moon three years later, but never achieved his dream of walking on the lunar surface, died on Monday at his home in San Marcos, Calif., near San Diego. He was 88.

His death was confirmed by NASA.

Mr. Gordon and Charles Conrad flew in the September 1966 Gemini 11 mission to advance the technique for the rendezvous and docking of two spacecraft, a procedure required for moon landings. They soared to 850 miles above the earth, setting a record for manned spaceflight.

Mr. Gordon piloted the command module Yankee Clipper during its orbit of the moon in November 1969 while Mr. Conrad and his fellow Apollo 12 astronaut Alan Bean carried out the first extensive moonwalks, four months after the pioneering Apollo 11 mission that sent Neil Armstrong and Buzz Aldrin to the moon.

After taking photos of the moon’s topography to scout tentative landing sites for future missions, Mr. Gordon performed docking maneuvers, allowing his fellow astronauts to return to the capsule in the lunar lander that had descended from it.