We examine the microscopic pinning of a contact line on a single heterogeneity. We find that many features of this behavior are predicted by models based on the same energy functionals which describe macroscopic contact angle hysteresis on surfaces with many such imperfections. As the defect emerges from the undistorted contact line, the contact line pins, increasingly distorts, slides across the defect, and then jumps back to an undistorted position. The distortion of a stably pinned contact line is described by a logarithmic dependence. While the force pinning the contact line depends on the defect microstructure, the elastic restoring force follows Hooke's law and is dependent on the properties of the fluid and contact angle on the underlying surface. The sliding motion and unstable jumps of the contact line occur at small capillary numbers.