By a cone is meant a warped product I x g F, where I is an interval and the warping function g : I -> R->= 0 lies in FK, i. e., satisfies g '' + Kg = 0. Cones include metric products and linear cones ( K = 0), hyperbolic, parabolic, and elliptical cones ( K < 0), and spherical suspensions ( K > 0). A cone over a geodesic metric space supports a natural K-affine function, that is, a function whose restriction to every unit-speed geodesic is in F K. Conversely, the main theorems of this paper show that on an Alexandrov space X of curvature bounded below or above, the existence of a nonconstant K-affine function f forces X to split as a cone ( subject to a boundary condition or geodesic completeness, respectively). For K = 0 and curvature bounded below, X splits as a metric product with a line; this case is due to Mashiko ( 2002). Some special cases for complete Riemannian manifolds were discovered much earlier: by Obata ( 1962), for K > 0, with the strong conclusion that X is a standard sphere; and by Innami ( 1982), for K = 0. For K < 0, with the additional assumption that f has a critical point, our theorem now gives the dual to Obata's theorem, namely, X is hyperbolic space.