The crew of Gemini VIII was the first to link two spacecraft together in Earth orbit. 

This great milestone would prove vital to the success of future Moon landing missions. But the triumph quickly became an in-flight emergency, testing NASA’s quick thinking skills to bring the astronauts safely home. While the spacecraft was docked to the Agena, a critical failure of the spacecraft threatened the lives of the astronauts and required immediate undocking, abort of the mission and emergency landing.

This photograph taken by David Scott with the Hasselblad 500C shows the Agena piloted by Neil Armstrong at only 24 inches from the nose of Gemini VIII that was off the coast of Brazil near Rio de Janeiro as the Sun was setting over the Earth. The docking adapter end and instrument panel of the Agena are clearly visible.

From the mission transcript during docking:

006:32:21 Armstrong:

Okay. We’re sitting about 2 feet out. [...]

006:32:23 Armstrong:

... We’ll go ahead and dock. [...]

006:33:40 Capcom (Mission Control):

Okay, Gemini VIII. It looks good here from the ground. We’re showing CONE RIGID. Everything looks good for the docking. [...]

006:33:52 Armstrong:

Flight, we are docked!

006:33:58 Armstrong:

Yes. It’s a - really a smoothie.

006:34:01 Capcom:

Roger. Hey, congratulations: This is real good.

006:34:07 Scott:

You couldn’t have the thrill down there that we have up here.

006:34:10 Capcom:

Ha! Ha! Ha!

006:34:24 Armstrong:

Okay. Just for your information, the Agena was very stable and at the present time we are having no noticeable oscillations at all.