A new method for sensing cantilever deflection in the atomic force microscope (AFM), based on capacitance measurement, is described. Parameters governing the design of such an instrument are considered in detail. Two different geometries are compared, wire on plate and an integrated flat plate sensor. The electronic circuitry, providing 6×10-19 F noise in a 0.01-1000 Hz bandwidth, is also described. Implementation of the design ideas into a working AFM in ultrahigh vacuum is demonstrated. This AFM allows simultaneous measurement of cantilever deflection in two orthogonal directions, necessary for our nanotribology studies. The theoretical sensitivity of 5×10-7 F/m is not achieved due to roughness. The bidirectional sensing and imaging capabilities are demonstrated for an Ir tip on cleaved graphite, and a diamond tip on diamond films. The capacitance detection technique is compared and contrasted with other AFM sensors.