Chemical control over the energy-level alignment in a two-terminal junction