Consider the closed multimap $\Pi:X\to 2^T$, whose graph is the closed set $\mathrm{graph}(\Pi):=\big\{(x,t)\in X\times T\, : d(x,t)=\min_{s\in T}d(x,s)\big\}\subset X\times T$. You want a measurable selection $\pi:X\to T$ of $\Pi$, that is $\mathrm{graph}(\pi)\subset\mathrm{graph}(\Pi)$. Since $K$ is a compact metric space, thus a Polish space, the classical Kuratowski–Ryll-Nardzewski measurable selection theorem does the job.

**rmk.** The Kuratowski–Ryll-Nardzewski measurable selection theorem admits an easy proof in the particular case of a closed, non-empty set valued multimap $\Pi:X\to2^T$ with $T$ a compact metric space. In this case (by the Alexandroff-Hausdorff theorem) $T$ is a continuous image $T=\kappa( C)$ of the Cantor set $C$ via some continuous surjective map $\kappa:C\to T$. The pre-image of the closed set $\mathrm{graph}(\Pi)$ via $\mathrm{id}_X\times\kappa:X\times C\to X\times T$ is therefore the graph of a closed multimap $X\to 2^C$, that is the multimap $x\mapsto \kappa^{-1}\Pi(x)\neq\emptyset;$ a lower semi-continuous, hence measurable selection of the latter, is $x\mapsto \min\kappa^{-1}\Pi(x) $, and a measurable selection of $\Pi$ is therefore

$$\pi(x):=\kappa\big(\min\kappa^{-1}\Pi(x)\big)\in\Pi(x).$$