A function *f*:**X**→**Y** between two metric spaces **X** and **Y** is called an *isometry* if it preserves distances, i.e. if d_{X}(*a,b*)=d_{Y}(*f(a),f(b)*) for all *a,b* in **X**.

Note that an isometry must be one to one, but needn't be onto. However, in many cases this is sufficient to ensure it must be onto, and indeed the term is often used in this more restricted manner even when this is not the case.

An isometry is a homomorphism of metric spaces.