Distance determination in animals can be achieved by visual or non-visual cues. Weakly electric fish use active electrolocation for orientation in the dark. By perceiving self-produced electric signals with epidermal electroreceptors, fish can detect, locate and analyse nearby objects. Distance discrimination, however, was thought to be hardly possible because it was assumed that confusing ambiguity could arise with objects of unknown sizes and materials. Here we show that during electrolocation electric fish can measure the distance of most objects accurately, independently of size, shape and material. Measurements of the 'electric image' projected onto the skin surface during electrolocation revealed only one parameter combination that was unambiguously related to object distance: the ratio between maximal image slope and maximal image amplitude. However, slope-to-amplitude ratios for spheres were always smaller than those for other objects. As predicted, these objects were erroneously judged by the fish to be further away than all other objects at an identical distance. Our results suggest a novel mechanism for depth perception that can be achieved with a single, stationary two-dimensional array of detectors.