For a system at a temperature of absolute zero, all thermal fluctuations are frozen out, while quantum fluctuations prevail. These microscopic quantum fluctuations can induce a macroscopic phase transition in the ground state of a many-body system when the relative strength of two competing energy terms is varied across a critical value. Here we observe such a quantum phase transition in a Bose-Einstein condensate with repulsive interactions, held in a three-dimensional optical lattice potential. As the potential depth of the lattice is increased, a transition is observed from a superfluid to a Mott insulator phase. In the superfluid phase, each atom is spread out over the entire lattice, with long-range phase coherence. But in the insulating phase, exact numbers of atoms are localized at individual lattice sites, with no phase coherence across the lattice; this phase is characterized by a gap in the excitation spectrum. We can induce reversible changes between the two ground states of the system.