Nanoelectronic devices operating in the quantum regime require coherent manipulation and control over electrons at atomic length and time scales. We demonstrate coherent control over electrons in a tunnel junction of a scanning tunneling microscope by means of precise tuning of the carrier-envelope phase of two-cycle long (<6-femtosecond) optical pulses. We explore photon and field-driven tunneling, two different regimes of interaction of optical pulses with the tunnel junction, and demonstrate a transition from one regime to the other. Our results show that it is possible to induce, track, and control electronic current at atomic scales with subfemtosecond resolution, providing a route to develop petahertz coherent nanoelectronics and microscopy.