Using piezoresponse force microscopy in an ultrahigh vacuum, polarization switching has been detected and quantified in epitaxial BiFeO3 films from 200 to about 4 unit cells thick. Local remnant piezoresponse was utilized to probe both ferroelectric properties and effects of imperfect electrical contacts. It was found that the shape of electromechanical hysteresis loops is strongly influenced by an extrinsic dielectric gap, primarily through the suppressing effect of the depolarizing field on the spontaneous polarization in the ultrathin films. Furthermore, statistical analysis of the hysteresis loops has revealed lateral variation of the extrinsic dielectric gap with sub–10-nm resolution. Robust and reproducible ferroelectric properties of nanoscale BiFeO3 indicate its potential for nanoscale applications in information storage and spintronics.