We introduce an analogue of the theory of length spaces into the setting of Lorentzian geometry and causality theory. The r^ole of the metric is taken over by the time separation function, in terms of which all basic notions are formulated. In this way we recover many fundamental results in greater generality, while at the same time clarifying the minimal requirements for and the interdependence of the basic building blocks of the theory. A main focus of this work is the introduction of synthetic curvature bounds, akin to the theory of Alexandrov and CAT$(k)$-spaces, based on triangle comparison. Applications include Lorentzian manifolds with metrics of low regularity, closed cone structures, and certain approaches to quantum gravity.