We present a theoretical study of a three-terminal nanoelectromechanical device consisting of a conducting carbon nanotube cantilever attached to a source electrode. The cantilever is positioned on a terraced silicon substrate and may be bent by applying a voltage on a gate electrode on the lower terrace. As a result of the bending, tunneling between the cantilever tip and a drain electrode on the lower terrace is greatly enhanced, and the electric circuit between the source and drain electrodes is closed. We analyze the switching characteristics of this nanorelay using a model that combines the mechanical motion of the cantilever with the orthodox theory of stationary single electron transistors, and conclude that the nanorelay may be used as a logical switch in the gigahertz regime.