When Shatner asked if Cmdr Hadfield was tweeting from space, the astronaut replied: "Yes, Standard Orbit, Captain. And we're detecting signs of life on the surface".
The message presumably refers to earth.
Cmdr Hadfield arrived at the International Space Station on 21 December for a five-month mission.
The exchange, which astronaut Buzz Aldrin also participated in, delighted Star Trek fans.
Space and science blogger Jason Major tweeted: "Looks like @WilliamShatner has opened a hailing frequency to the #ISS and @Cmdr-Hadfield answered! #cool", in reaction to the Twitter exchange.
Cmdr Hadfield has been tweeting images of earth, including photographs of snow-covered rice fields in Japan and the coast of Italy.
The Canadian Space Agency has offered to arrange a live tweeting session between the actor and the astronaut.
Canadian astronaut Chris Hadfield has exchanged tweets from space with William Shatner, who played Captain Kirk in Star Trek.