Gauge theories are fundamental to our understanding of interactions between the elementary constituents of matter as mediated by gauge bosons. However, computing the real-time dynamics in gauge theories is a notorious challenge for classical computational methods. In the spirit of Feynman's vision of a quantum simulator, this has recently stimulated theoretical effort to devise schemes for simulating such theories on engineered quantum-mechanical devices, with the difficulty that gauge invariance and the associated local conservation laws (Gauss laws) need to be implemented. Here we report the first experimental demonstration of a digital quantum simulation of a lattice gauge theory, by realising 1+1-dimensional quantum electrodynamics (Schwinger model) on a few-qubit trapped-ion quantum computer. Our work represents a first step towards quantum simulating high-energy theories with atomic physics experiments, the long-term vision being the extension to real-time quantum simulations of non-Abelian lattice gauge theories.