Wave-particle duality is one of the basic features of quantum mechanics, giving rise to the use of complex numbers in describing states of quantum systems, their dynamics, and interaction. Since the inception of quantum theory, it has been debated whether complex numbers are actually essential, or whether an alternative consistent formulation is possible using real numbers only. Here, we attack this long-standing problem both theoretically and experimentally, using the powerful tools of quantum resource theories. We show that - under reasonable assumptions - quantum states are easier to create and manipulate if they only have real elements. This gives an operational meaning to the resource theory of imaginarity. We identify and answer several important questions which include the state-conversion problem for all qubit states and all pure states of any dimension, and the approximate imaginarity distillation for all quantum states. As an application, we show that imaginarity plays a crucial role for state discrimination: there exist real quantum states which can be perfectly distinguished via local operations and classical communication, but which cannot be distinguished with any nonzero probability if one of the parties has no access to imaginarity. We confirm this phenomenon experimentally with linear optics, performing discrimination of different two-photon quantum states by local projective measurements. These results prove that complex numbers are an indispensable part of quantum mechanics.