We study the electronic states and current–voltage (I–V) characteristics of junction systems with atomic-scale nanocontacts as a function of the distance between electrodes by using the first-principles recursion-transfer-matrix (RTM) method combined with nonequilibrium Green function (NEGF) method. We observe a strong nonlinear behavior in the I–V characteristics and correspondingly a gap structure emerges in the differential conductance. We find that such a nonlinear behavior appears when the transport properties change from tunneling to ballistic regimes.