[guided]The workhorse here is the [Hopf–Rinow theorem](/theorems/2719), which packages three equivalent properties of a Riemannian manifold and one important consequence: (i) geodesic completeness (every geodesic extends to all of $\mathbb{R}$, i.e., the exponential map is defined on all of $T_pM$) is equivalent to metric completeness as a metric space, (ii) closed bounded subsets are compact (the Heine–Borel property), and (iii) any two points are joined by a *minimizing* geodesic. Our hypothesis is metric completeness, so all three properties are available. We use (iii) right now to produce the joining geodesics; (ii) will reappear in Step 3 for Arzelà–Ascoli.
Applied with the points $p_n, q_n \in M$, Hopf–Rinow yields, for each $n$, a unit-speed minimizing geodesic from $p_n$ to $q_n$:
\begin{align*}
\gamma_n : [0, L_n] &\to M, \qquad L_n := d_g(p_n, q_n) > 0, \\
\gamma_n(0) &= p_n, \quad \gamma_n(L_n) = q_n, \quad |\dot\gamma_n| \equiv 1, \quad L(\gamma_n|_{[0, L_n]}) = L_n.
\end{align*}
Here $L(\cdot)$ denotes Riemannian arclength, the length of the parameter interval coincides with the distance $L_n$ (this is what "minimizing" means), and unit speed is achieved by the standard arclength reparametrization.
Next, we observe that $\gamma_n$ must cross $K$. Why? This is purely topological: $A_1, A_2$ are disjoint open subsets of $M \setminus K$. The image $\gamma_n([0, L_n])$ is a path-connected subset of $M$ joining $p_n \in A_1$ and $q_n \in A_2$. If $\gamma_n([0, L_n])$ were disjoint from $K$, it would lie in $M \setminus K$ and, being path-connected, would lie inside a single connected component. But its endpoints are in different components, a contradiction. Hence there exists $t_n \in [0, L_n]$ with $\gamma_n(t_n) \in K$ — this is the content of the claim above.
Now we *center* the family at $K$ by reparametrizing so that the crossing point sits at parameter $0$:
\begin{align*}
\tilde\gamma_n : [-t_n, L_n - t_n] &\to M, \\
\tilde\gamma_n(s) &:= \gamma_n(s + t_n).
\end{align*}
This is just a shift of the parameter; minimality, unit speed, and arclength are unchanged. We have $\tilde\gamma_n(0) = \gamma_n(t_n) \in K$, $\tilde\gamma_n(-t_n) = p_n$, and $\tilde\gamma_n(L_n - t_n) = q_n$. Set
\begin{align*}
a_n &:= t_n = d_g(\gamma_n(t_n), p_n) \geq d_g(p_n, K), \\
b_n &:= L_n - t_n = d_g(\gamma_n(t_n), q_n) \geq d_g(q_n, K).
\end{align*}
The first equality holds because $\tilde\gamma_n|_{[-a_n, 0]}$ is a unit-speed minimizing path of length $a_n$ from $p_n$ to $\gamma_n(t_n)$; minimizing means its length equals the distance between its endpoints. The first inequality holds because $\gamma_n(t_n) \in K$, so $d_g(p_n, K) \leq d_g(p_n, \gamma_n(t_n)) = a_n$ (the distance to a set is the infimum of distances to points in the set, and $\gamma_n(t_n)$ is one such point). Symmetrically for $b_n$.
Combining with the choice of $p_n, q_n$ from Step 1,
\begin{align*}
a_n \to \infty \quad \text{and} \quad b_n \to \infty \quad \text{as } n \to \infty.
\end{align*}
This is the key geometric fact we have established: as $n \to \infty$, we have longer and longer unit-speed minimizing geodesics passing through a fixed compact set $K$ at parameter $s = 0$, with the parameter interval $[-a_n, b_n]$ extending to infinity in *both* directions. This two-sided unboundedness is exactly what disconnectedness at infinity bought us.[/guided]