Nasa astronaut Kate Rubins carried out the test on the International Space Station (ISS) at the weekend.
She was using a compact DNA sequencing device called Minion, which was developed in the UK.
The device, which was sent up to the space station in July, could help astronauts diagnose illness in space and allow them to identify disease-causing microbes on the ISS.
DNA sequencing is the process used to determine the order of the four chemical building blocks that make up the genetic information from a given living organism.
While Dr Rubins carried out her work on the orbiting outpost, researchers were simultaneously sequencing identical test samples on the ground.
The experiment was set up to attempt to make spaceflight conditions, particularly microgravity, the only variables that could account for differences in the results.
Using the Minion in a weightless environment introduces several challenges including the formation of air bubbles in fluid used in the test.
Bubbles rise to the top of a liquid solution and can be removed by centrifuge. But in space, bubbles are less predictable.
Sarah Castro-Wallace, project manager for the experiment, said: “Onboard sequencing makes it possible for the crew to know what is in their environment at any time.
“That allows us on the ground to take appropriate action – do we need to clean this up right away, or will taking antibiotics help or not?
“We can resupply the station with disinfectants and antibiotics now, but once crews move beyond the station’s low Earth orbit, we need to know when to save those precious resources and when to use them.”