[proofplan]
We prove both implications using the metric characterization of precompactness as [total boundedness](/page/Total%20Boundedness). If $\overline{A}$ is compact, then every $\varepsilon$-ball cover of $\overline{A}$ has a finite subcover, so $A$ is totally bounded and hence precompact. Conversely, if $A$ is precompact, then $A$ is totally bounded; we show directly that $\overline{A}$ is also totally bounded. Since $\overline{A}$ is a closed subspace of the [complete metric space](/page/Complete%20Metric%20Space) $X$, it is complete, and a complete totally bounded [metric space](/page/Metric%20Space) is compact.
[/proofplan]
[step:Deduce total boundedness of $A$ from compactness of $\overline{A}$]
Assume that $A$ is relatively compact in $X$. By definition, this means that $\overline{A}$ is compact in the metric topology induced by $d$.
Let $\varepsilon > 0$. For each $x \in \overline{A}$, define the open ball $B_X(x,\varepsilon) := \{y \in X : d(x,y) < \varepsilon\}$. The family $\{B_X(x,\varepsilon) \cap \overline{A} : x \in \overline{A}\}$ is an [open cover](/page/Open%20Cover) of $\overline{A}$ in the [subspace topology](/page/Subspace%20Topology). Since $\overline{A}$ is compact, there exist points $x_1,\dots,x_N \in \overline{A}$ such that $\overline{A} \subset \bigcup_{i=1}^{N} B_X(x_i,\varepsilon)$. Because $A \subset \overline{A}$, the same finite family covers $A$. Thus $A$ is totally bounded. By [citetheorem:8517], total boundedness is equivalent to precompactness in a metric space, so $A$ is precompact.
[/step]
[step:Show that the closure of a precompact set is totally bounded]
Assume that $A$ is precompact. By [citetheorem:8517], $A$ is totally bounded.
Let $C := \overline{A}$, regarded as a metric subspace of $X$ with the restricted metric $d_C: C \times C \to [0,\infty)$ given by $d_C(x,y) := d(x,y)$. We prove that $C$ is totally bounded. Let $\varepsilon > 0$. Since $A$ is totally bounded, there exist points $a_1,\dots,a_N \in A$ such that $A \subset \bigcup_{i=1}^{N} B_X(a_i,\varepsilon/2)$. Let $x \in C$. Since $x \in \overline{A}$, the ball $B_X(x,\varepsilon/2)$ intersects $A$, so choose $y \in A$ with $d(x,y) < \varepsilon/2$. Since the balls $B_X(a_i,\varepsilon/2)$ cover $A$, there exists an index $i \in \{1,\dots,N\}$ such that $d(y,a_i) < \varepsilon/2$. By the triangle inequality, $d(x,a_i) \leq d(x,y) + d(y,a_i) < \varepsilon$. Therefore $C \subset \bigcup_{i=1}^{N} B_X(a_i,\varepsilon)$. Since $\varepsilon > 0$ was arbitrary, $C=\overline{A}$ is totally bounded.
[guided]
The point of this step is that total boundedness survives passage to closure. We start from the precompactness of $A$ and translate it into total boundedness using [citetheorem:8517]. Thus, for every radius $\delta > 0$, finitely many $\delta$-balls centered at points of $A$ cover $A$.
Let $C := \overline{A}$, with restricted metric $d_C(x,y) := d(x,y)$ for $x,y \in C$. To show that $C$ is totally bounded, fix $\varepsilon > 0$. We deliberately cover $A$ by balls of radius $\varepsilon/2$, not $\varepsilon$, because a point of $C$ may not lie in $A$; we first approximate it by a point of $A$, and then use the finite cover of $A$.
Since $A$ is totally bounded, choose $a_1,\dots,a_N \in A$ such that $A \subset \bigcup_{i=1}^{N} B_X(a_i,\varepsilon/2)$. Now take any $x \in C$. By the definition of closure, every open ball around $x$ intersects $A$. In particular, there exists $y \in A$ such that $d(x,y) < \varepsilon/2$. Since $y \in A$, the finite cover above gives an index $i \in \{1,\dots,N\}$ such that $d(y,a_i) < \varepsilon/2$. Applying the triangle inequality gives $d(x,a_i) \leq d(x,y) + d(y,a_i) < \varepsilon$. Thus every $x \in C$ lies in one of the finitely many balls $B_X(a_i,\varepsilon)$. Since $\varepsilon > 0$ was arbitrary, $C=\overline{A}$ is totally bounded.
[/guided]
[/step]
[step:Use completeness of $X$ to make $\overline{A}$ complete]
Let $C := \overline{A}$ with the restricted metric $d_C$. Since $C$ is closed in $X$ by definition of closure, every sequence in $C$ that converges in $X$ has its limit in $C$.
Let $(x_n)_{n=1}^{\infty}$ be a [Cauchy sequence](/page/Cauchy%20Sequence) in $(C,d_C)$. Since $d_C$ is the restriction of $d$, the same sequence is Cauchy in $(X,d)$. Because $(X,d)$ is complete, there exists $x \in X$ such that $x_n \to x$ in the metric $d$. Since each $x_n \in C$ and $C$ is closed in $X$, we have $x \in C$. Therefore every Cauchy sequence in $C$ converges in $C$, so $(C,d_C)$ is complete.
[/step]
[step:Conclude compactness of $\overline{A}$ from completeness and total boundedness]
From the previous steps, $C=\overline{A}$ is both complete and totally bounded. The metric-space compactness criterion says that every complete totally bounded metric space is compact. Hence $(C,d_C)$ is compact.
Since compactness of the subspace $(C,d_C)$ is exactly compactness of $\overline{A}$ in $X$, the closure $\overline{A}$ is compact. Therefore $A$ is relatively compact in $X$. This proves the reverse implication and completes the equivalence.
[/step]