K channels control transmembrane action potentials by gating open or closed in response to external stimuli. Inactivation gating, involving a conformational change at the K selectivity filter, has recently been recognized as a major K channel regulatory mechanism. In the K channel hERG, inactivation controls the length of the human cardiac action potential. Mutations impairing hERG inactivation cause life-threatening cardiac arrhythmia, which also occur as undesired side effects of drugs. In this paper, we report atomistic molecular dynamics simulations, complemented by mutational and electrophysiological studies, which suggest that the selectivity filter adopts a collapsed conformation in the inactivated state of hERG. The selectivity filter is gated by an intricate hydrogen bond network around residues S620 and N629. Mutations of this hydrogen bond network are shown to cause inactivation deficiency in electrophysiological measurements. In addition, drug-related conformational changes around the central cavity and pore helix provide a functional mechanism for newly discovered hERG activators.