The ability to detect extremely small forces and nanoscale displacements is vital for disciplines such as precision spin-resonance imaging, microscopy, and tests of fundamental physical phenomena. Current force-detection sensitivity limits have surpassed 1 aN Hz(-1/2) (refs 6,7) through coupling of nanomechanical resonators to a variety of physical readout systems. Here, we demonstrate that crystals of trapped atomic ions behave as nanoscale mechanical oscillators and may form the core of exquisitely sensitive force and displacement detectors. We report the detection of forces with a sensitivity of 390 +/- 150 yN Hz(-1/2), which is more than three orders of magnitude better than existing reports using nanofabricated devices(7), and discriminate ion displacements of approximately 18 nm. Our technique is based on the excitation of tunable normal motional modes in an ion trap and detection through phase-coherent Doppler velocimetry, and should ultimately allow force detection with a sensitivity better than 1 yN Hz(-1/2) (ref. 16). Trapped-ion-based sensors could enable scientists to explore new regimes in materials science where augmented force, field and displacement sensitivity may be traded against reduced spatial resolution.