Cells employ membrane-embedded antiporter proteins to control their pH, salt concentration, and volume. The large family of cation/proton antiporters is dominated by Na+/H+ antiporters that exchange sodium ions against protons, but homologous K+/H+ exchangers have recently been characterized. We show experimentally that the electroneutral antiporter NhaP1 of Methanocaldococcus jannaschii (MjNhaP1) is highly selective for Na+ ions. We then characterize the ion selectivity in both the inward-open and outward-open states of MjNhaP1 using classical molecular dynamics simulations, free energy calculations, and hybrid quantum/classical (QM/MM) simulations. We show that MjNhaP1 is highly selective for binding of Na+ over K+ in the inward-open state, yet it is only weakly selective in the outward-open state. These findings are consistent with the function of MjNhaP1 as a sodium-driven deacidifier of the cytosol that maintains a high cytosolic K+ concentration in environments of high salinity. By combining experiment and computation, we gain mechanistic insight into the Na+/H+ transport mechanism and help elucidate the molecular basis for ion selectivity in cation/proton exchangers.