Motor proteins and other biological machines are highly efficient at converting energy into directed motion and driving chemical systems away from thermodynamic equilibrium1. But even though these biological structures have inspired the design of many molecules that mimic aspects of their behaviour2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, artificial nanomachine systems operate almost exclusively by moving towards thermodynamic equilibrium, not away from it. Here we show that information about the location of a macrocycle in a rotaxane—a molecular ring threaded onto a molecular axle—can be used, on the input of light energy, to alter the kinetics of the shuttling of the macrocycle between two compartments on the axle. For an ensemble of such molecular machines, the macrocycle distribution is directionally driven away from its equilibrium value without ever changing the relative binding affinities of the ring for the different parts of the axle. The selective transport of particles between two compartments by brownian motion in this way bears similarities to the hypothetical task performed without an energy input by a 'demon' in Maxwell's famous thought experiment16, 17, 18, 19. Our observations demonstrate that synthetic molecular machines can operate by an information ratchet mechanism20, 21, 22, in which knowledge of a particle's position is used to control its transport away from equilibrium.