We study the optimal transport between two probability measures on the real line, where the transport plans are laws of one-step martingales. A quasi-sure formulation of the dual problem is introduced and shown to yield a complete duality theory for general marginals and measurable reward (cost) functions: absence of a duality gap and existence of dual optimizers. Both properties are shown to fail in the classical formulation. As a consequence of the duality result, we obtain a general principle of cyclical monotonicity describing the geometry of optimal transports.