The magnetoelectric effect--the induction of magnetization by means of an electric field and induction of polarization by means of a magnetic field--was first presumed to exist by Pierre Curie, and subsequently attracted a great deal of interest in the 1960s and 1970s (refs 2-4). More recently, related studies on magnetic ferroelectrics have signalled a revival of interest in this phenomenon. From a technological point of view, the mutual control of electric and magnetic properties is an attractive possibility, but the number of candidate materials is limited and the effects are typically too small to be useful in applications. Here we report the discovery of ferroelectricity in a perovskite manganite, TbMnO3, where the effect of spin frustration causes sinusoidal antiferromagnetic ordering. The modulated magnetic structure is accompanied by a magnetoelastically induced lattice modulation, and with the emergence of a spontaneous polarization. In the magnetic ferroelectric TbMnO3, we found gigantic magnetoelectric and magnetocapacitance effects, which can be attributed to switching of the electric polarization induced by magnetic fields. Frustrated spin systems therefore provide a new area to search for magnetoelectric media.