The interplay of magnetic interactions, the dimensionality of the crystal structure and electronic correlations in producing superconductivity is one of the dominant themes in the study of the electronic properties of complex materials. Although magnetic interactions and two-dimensional structures were long thought to be detrimental to the formation of a superconducting state, they are actually common features of both the high transition-temperature (T c) copper oxides and low-T c material Sr2RuO4, where they appear to be essential contributors to the exotic electronic states of these materials1. Here we report that the perovskite-structured compound MgCNi3 is superconducting with a critical temperature of 8 K. This material is the three-dimensional analogue of the LnNi2B2C family of superconductors, which have critical temperatures up to 16 K (ref. 2). The itinerant electrons in both families of materials arise from the partial filling of the nickel d-states, which generally leads to ferromagnetism as is the case in metallic Ni. The high relative proportion of Ni in MgCNi3 suggests that magnetic interactions are important, and the lower T c of this three-dimensional compound—when compared to the LnNi2B2C family—contrasts with conventional ideas regarding the origins of superconductivity.