Polar molecules have a rich internal structure and long-range dipole-dipole interactions, making them useful for quantum-controlled applications and fundamental investigations. Their potential fully unfolds at ultracold temperatures, where various effects are predicted in many-body physics, quantum information science, ultracold chemistry and physics beyond the standard model. Whereas a wide range of methods to produce cold molecular ensembles have been developed, the cooling of polyatomic molecules (that is, with three or more atoms) to ultracold temperatures has seemed intractable. Here we report the experimental realization of optoelectrical cooling, a recently proposed cooling and accumulation method for polar molecules. Its key attribute is the removal of a large fraction of a molecule's kinetic energy in each cycle of the cooling sequence via a Sisyphus effect, allowing cooling with only a few repetitions of the dissipative decay process. We demonstrate the potential of optoelectrical cooling by reducing the temperature of about one million CH3F molecules by a factor of 13.5, with the phase-space density increased by a factor of 29 (or a factor of 70 discounting trap losses). In contrast to other cooling mechanisms, our scheme proceeds in a trap, cools in all three dimensions and should work for a large variety of polar molecules. With no fundamental temperature limit anticipated down to the photon-recoil temperature in the nanokelvin range, we expect our method to be able to produce ultracold polyatomic molecules. The low temperatures, large molecule numbers and long trapping times of up to 27 seconds should allow an interaction-dominated regime to be attained, enabling collision studies and investigation of evaporative cooling towards a Bose-Einstein condensate of polyatomic molecules.