[step:Transport the isomorphism to the basepoint $x_0$ via change of basepoint]
So far we have $\pi_1(Y, y_1) \cong \pi_1(A, y_1)$. We now recover $\pi_1(Y, x_0) \cong \pi_1(X, x_0)$ at the specified basepoint $x_0$ in the image of $f$, i.e., $x_0 \in q(S^{n-1}) \subseteq X$.
Since $Y$ is path-connected (as a union of path-connected sets sharing $y_1 \in A \cap B$), choose a path $\gamma: [0,1] \to Y$ from $y_1$ to $x_0$. By the [Change of Basepoint](/theorems/1880) theorem, $\gamma$ induces an isomorphism
\begin{align*}
\gamma_\#: \pi_1(Y, y_1) &\xrightarrow{\;\cong\;} \pi_1(Y, x_0), & [\alpha] &\mapsto [\bar\gamma \cdot \alpha \cdot \gamma].
\end{align*}
Similarly, since $x_0 \in X \subseteq A$ and $A \simeq X$ is path-connected, there is a path $\gamma'$ in $A$ from $y_1$ to $x_0$, inducing
\begin{align*}
\gamma'_\#: \pi_1(A, y_1) \xrightarrow{\;\cong\;} \pi_1(A, x_0).
\end{align*}
Finally, the deformation retraction $A \to X$ from Step 2 is a homotopy equivalence, so by the [homotopy invariance of the fundamental group](/theorems/1882), the inclusion $X \hookrightarrow A$ induces an isomorphism $\pi_1(X, x_0) \xrightarrow{\cong} \pi_1(A, x_0)$ (using $x_0 \in X$ as basepoint on both sides).
Composing the isomorphisms:
\begin{align*}
\pi_1(X, x_0) \xrightarrow{\;\cong\;} \pi_1(A, x_0) \xrightarrow{(\gamma'_\#)^{-1}} \pi_1(A, y_1) \xrightarrow{\;\cong\;} \pi_1(Y, y_1) \xrightarrow{\gamma_\#} \pi_1(Y, x_0),
\end{align*}
where the middle isomorphism is the Seifert–van Kampen isomorphism of Step 3. The total composition is the homomorphism induced by the inclusion $X \hookrightarrow Y$: at each step we pass through the natural inclusion or deformation-retraction, and the basepoint-change paths are chosen compatibly inside $A$. Hence the inclusion $X \hookrightarrow Y$ induces an isomorphism $\pi_1(X, x_0) \xrightarrow{\cong} \pi_1(Y, x_0)$, completing the proof.
[/step]