Bulk water exists in many forms, including liquid, vapour and numerous crystalline and amorphous phases of ice, with hexagonal ice being responsible for the fascinating variety of snowflakes. Much less noticeable but equally ubiquitous is water adsorbed at interfaces and confined in microscopic pores. Such low-dimensional water determines aspects of various phenomena in materials science, geology, biology, tribology and nanotechnology. Theory suggests many possible phases for adsorbed and confined water, but it has proved challenging to assess its crystal structure experimentally. Here we report high-resolution electron microscopy imaging of water locked between two graphene sheets, an archetypal example of hydrophobic confinement. The observations show that the nanoconfined water at room temperature forms `square ice'--a phase having symmetry qualitatively different from the conventional tetrahedral geometry of hydrogen bonding between water molecules. Square ice has a high packing density with a lattice constant of 2.83 Å and can assemble in bilayer and trilayer crystallites. Molecular dynamics simulations indicate that square ice should be present inside hydrophobic nanochannels independently of their exact atomic nature.