The integral membrane protein M2 of influenza virus forms pH-gated proton channels in the viral lipid envelope. The low pH of an endosome activates the M2 channel before haemagglutinin-mediated fusion. Conductance of protons acidifies the viral interior and thereby facilitates dissociation of the matrix protein from the viral nucleoproteins--a required process for unpacking of the viral genome. In addition to its role in release of viral nucleoproteins, M2 in the trans-Golgi network (TGN) membrane prevents premature conformational rearrangement of newly synthesized haemagglutinin during transport to the cell surface by equilibrating the pH of the TGN with that of the host cell cytoplasm. Inhibiting the proton conductance of M2 using the anti-viral drug amantadine or rimantadine inhibits viral replication. Here we present the structure of the tetrameric M2 channel in complex with rimantadine, determined by NMR. In the closed state, four tightly packed transmembrane helices define a narrow channel, in which a 'tryptophan gate' is locked by intermolecular interactions with aspartic acid. A carboxy-terminal, amphipathic helix oriented nearly perpendicular to the transmembrane helix forms an inward-facing base. Lowering the pH destabilizes the transmembrane helical packing and unlocks the gate, admitting water to conduct protons, whereas the C-terminal base remains intact, preventing dissociation of the tetramer. Rimantadine binds at four equivalent sites near the gate on the lipid-facing side of the channel and stabilizes the closed conformation of the pore. Drug-resistance mutations are predicted to counter the effect of drug binding by either increasing the hydrophilicity of the pore or weakening helix-helix packing, thus facilitating channel opening.