The question of whether quantum phenomena can be explained by classical models with hidden variables is the subject of a long-lasting debate1, 2. In 1964, Bell showed that certain types of classical models cannot explain the quantum mechanical predictions for specific states of distant particles, and some types of hidden variable models3, 4, 5, 6, 7, 8, 9 have been experimentally ruled out. An intuitive feature of classical models is non-contextuality: the property that any measurement has a value independent of other compatible measurements being carried out at the same time. However, a theorem derived by Kochen, Specker and Bell10, 11, 12 shows that non-contextuality is in conflict with quantum mechanics. The conflict resides in the structure of the theory and is independent of the properties of special states. It has been debated whether the Kochen–Specker theorem could be experimentally tested at all13, 14. First tests of quantum contextuality have been proposed only recently, and undertaken with photons15, 16 and neutrons17, 18. But these tests required the generation of special quantum states and left various loopholes open. Here we perform an experiment with trapped ions that demonstrates a state-independent conflict with non-contextuality. The experiment is not subject to the detection loophole and we show that, despite imperfections and possible measurement disturbances, our results cannot be explained in non-contextual terms.