We prove a factorization theorem for Lipschitz operators acting on certain subsets of metric spaces of measurable functions and with values on general metric spaces. Our results show how a Lipschitz operator can be extended to a subset of other metric space of measurable functions that satisfies the following optimality condition: it is the biggest metric space, formed by measurable functions, to which the operator can be extended preserving the Lipschitz constant. As an application, we show the coarsest metric that can be given for a metric space in which an order bounded lattice-valued-Lipschitz map is defined. Concrete examples involving the relevant space L0(μ) are given.