Superconductivity develops from an attractive interaction between itinerant electrons that creates electron pairs which condense into a macroscopic quantum state--the superconducting state. On the other hand, magnetic order in a metal arises from electrons localized close to the ionic core and whose interaction is mediated by itinerant electrons. The dichotomy between local moment magnetic order and superconductivity raises the question of whether these two states can coexist and involve the same electrons. Here we show that the single 4f-electron of cerium in CeRhIn5 simultaneously produces magnetism, characteristic of localization, and superconductivity that requires itinerancy. The dual nature of the 4f-electron allows microscopic coexistence of antiferromagnetic order and superconductivity whose competition is tuned by small changes in pressure and magnetic field. Electronic duality contrasts with conventional interpretations of coexisting spin-density magnetism and superconductivity and offers a new avenue for understanding complex states in classes of materials.