The development of a variety of nanoscale applications requires the fabrication and control of atomic or molecular switches that can be reversibly operated by light, a short-range force, electric current or other external stimuli. For such molecules to be used as electronic components, they should be directly coupled to a metallic support and the switching unit should be easily connected to other molecular species without suppressing switching performance. Here, we show that a free-base tetraphenyl-porphyrin molecule, which is anchored to a silver surface, can function as a molecular conductance switch. The saddle-shaped molecule has two hydrogen atoms in its inner cavity that can be flipped between two states with different local conductance levels using the electron current through the tip of a scanning tunnelling microscope. Moreover, by deliberately removing one of the hydrogens, a four-level conductance switch can be created. The resulting device, which could be controllably integrated into the surrounding nanoscale environment, relies on the transfer of a single proton and therefore contains the smallest possible atomistic switching unit.