In data-driven inverse optimization an observer aims to learn the preferences of an agent who solves a parametric optimization problem depending on an exogenous signal. Thus, the observer seeks the agent's objective function that best explains a historical sequence of signals and corresponding optimal actions. We formalize this inverse optimization problem as a distributionally robust program minimizing the worst-case risk that the estimated decision (i.e., the decision implied by a particular candidate objective) differs from the agent's actual response to a random signal. We show that our framework offers attractive out-of-sample performance guarantees for different prediction errors and that the emerging inverse optimization problems can be reformulated as (or approximated by) tractable convex programs when the prediction error is measured in the space of objective values. A main strength of the proposed approach is that it naturally generalizes to situations where the observer has imperfect information, e.g., when the agent's true objective function is not contained in the space of candidate objectives, when the agent suffers from bounded rationality or implementation errors, or when the observed signal-response pairs are corrupted by measurement noise.