[proofplan]
We localise at the common contraction $\mathfrak{p} := \mathfrak{q} \cap A = \mathfrak{q}' \cap A$, reducing to a local base ring $A_\mathfrak{p}$. Both $\mathfrak{q}$ and $\mathfrak{q}'$ extend to primes of $B_\mathfrak{p}$ lying over the maximal ideal $\mathfrak{p}A_\mathfrak{p}$. By preservation of maximality under integral extensions, both extended primes are maximal. Since one is contained in the other, they must be equal, and contracting back gives $\mathfrak{q} = \mathfrak{q}'$.
[/proofplan]
[step:Set up the localisation at $\mathfrak{p} := \mathfrak{q} \cap A$]
Let $\mathfrak{p} := \mathfrak{q} \cap A = \mathfrak{q}' \cap A$ and set $S := A \setminus \mathfrak{p}$. Since $\mathfrak{q} \cap A = \mathfrak{p}$, we have $\mathfrak{q} \cap S = \varnothing$, and similarly $\mathfrak{q}' \cap S = \varnothing$ (using $\mathfrak{q}' \cap A = \mathfrak{p}$). By [Prime Ideals Under Localization](/theorems/2927), since both $\mathfrak{q}$ and $\mathfrak{q}'$ are prime ideals of $B$ disjoint from $S$, their extensions $S^{-1}\mathfrak{q}$ and $S^{-1}\mathfrak{q}'$ are prime ideals of $S^{-1}B = B_\mathfrak{p}$, and contracting back recovers the originals:
\begin{align*}
(S^{-1}\mathfrak{q}) \cap B = \mathfrak{q}, \qquad (S^{-1}\mathfrak{q}') \cap B = \mathfrak{q}'.
\end{align*}
[guided]
The idea is to replace $A \subset B$ by $A_\mathfrak{p} \subset B_\mathfrak{p}$, where $A_\mathfrak{p}$ is local with maximal ideal $\mathfrak{p}A_\mathfrak{p}$. This simplification is possible because localisation preserves the prime ideal structure above $\mathfrak{p}$.
We set $S = A \setminus \mathfrak{p}$. Both $\mathfrak{q}$ and $\mathfrak{q}'$ are disjoint from $S$: for $\mathfrak{q}$, if $s \in \mathfrak{q} \cap S$ then $s \in \mathfrak{q} \cap A = \mathfrak{p}$ and $s \in A \setminus \mathfrak{p}$, a contradiction; similarly for $\mathfrak{q}'$. By the standard correspondence between primes of $B$ disjoint from $S$ and primes of $S^{-1}B$ ([Prime Ideals Under Localization](/theorems/2927)), the localised ideals $S^{-1}\mathfrak{q}$ and $S^{-1}\mathfrak{q}'$ are prime in $B_\mathfrak{p}$, and the contraction maps $S^{-1}\mathfrak{q} \mapsto \mathfrak{q}$, $S^{-1}\mathfrak{q}' \mapsto \mathfrak{q}'$ are bijective on this set of primes.
[/guided]
[/step]
[step:Verify that both extended primes lie over the maximal ideal $\mathfrak{p}A_\mathfrak{p}$]
We compute the contraction of $S^{-1}\mathfrak{q}$ to $A_\mathfrak{p}$. By the compatibility of localisation with contraction:
\begin{align*}
S^{-1}\mathfrak{q} \cap A_\mathfrak{p} = S^{-1}(\mathfrak{q} \cap A) = S^{-1}\mathfrak{p} = \mathfrak{p}A_\mathfrak{p}.
\end{align*}
The same computation gives $S^{-1}\mathfrak{q}' \cap A_\mathfrak{p} = \mathfrak{p}A_\mathfrak{p}$. Therefore both $S^{-1}\mathfrak{q}$ and $S^{-1}\mathfrak{q}'$ are primes of $B_\mathfrak{p}$ lying over the unique maximal ideal $\mathfrak{p}A_\mathfrak{p}$ of $A_\mathfrak{p}$.
[/step]
[step:Apply preservation of maximality to conclude both extended primes are maximal]
By [Stability Under Quotients and Localisation](/theorems/2867), part (1b), the extension $A_\mathfrak{p} \subset B_\mathfrak{p}$ is integral (since $A \subset B$ is integral and localisation preserves integrality).
By [Maximality Is Preserved Under Integral Extensions](/theorems/2869), applied to the integral extension $A_\mathfrak{p} \subset B_\mathfrak{p}$: a prime $\mathfrak{Q}$ of $B_\mathfrak{p}$ is maximal if and only if $\mathfrak{Q} \cap A_\mathfrak{p}$ is maximal in $A_\mathfrak{p}$. Since $\mathfrak{p}A_\mathfrak{p}$ is the unique maximal ideal of the local ring $A_\mathfrak{p}$, and both $S^{-1}\mathfrak{q}$ and $S^{-1}\mathfrak{q}'$ contract to $\mathfrak{p}A_\mathfrak{p}$, both $S^{-1}\mathfrak{q}$ and $S^{-1}\mathfrak{q}'$ are maximal ideals of $B_\mathfrak{p}$.
[guided]
This is the key step where integrality is consumed. Without the integral extension hypothesis, there would be no link between maximality upstairs and downstairs.
The integral extension $A \subset B$ localises to an integral extension $A_\mathfrak{p} \subset B_\mathfrak{p}$ by [Stability Under Quotients and Localisation](/theorems/2867), part (1b). The theorem [Maximality Is Preserved Under Integral Extensions](/theorems/2869) states: for an integral extension $R \subset S$ and a prime $\mathfrak{Q}$ of $S$, $\mathfrak{Q}$ is maximal in $S$ iff $\mathfrak{Q} \cap R$ is maximal in $R$.
We have verified that $S^{-1}\mathfrak{q} \cap A_\mathfrak{p} = \mathfrak{p}A_\mathfrak{p}$, which is maximal in $A_\mathfrak{p}$ (it is the unique maximal ideal of the local ring). Therefore $S^{-1}\mathfrak{q}$ is maximal in $B_\mathfrak{p}$, and by the same argument $S^{-1}\mathfrak{q}'$ is maximal in $B_\mathfrak{p}$.
[/guided]
[/step]
[step:Use the inclusion of maximal ideals to conclude $\mathfrak{q} = \mathfrak{q}'$]
From $\mathfrak{q} \subset \mathfrak{q}'$, extending by $S^{-1}$ gives $S^{-1}\mathfrak{q} \subset S^{-1}\mathfrak{q}'$. But $S^{-1}\mathfrak{q}$ and $S^{-1}\mathfrak{q}'$ are both maximal ideals of $B_\mathfrak{p}$. A maximal ideal contained in another maximal ideal must equal it (since a maximal ideal is, by definition, not properly contained in any ideal other than the whole ring). Therefore $S^{-1}\mathfrak{q} = S^{-1}\mathfrak{q}'$.
Contracting back to $B$:
\begin{align*}
\mathfrak{q} = (S^{-1}\mathfrak{q}) \cap B = (S^{-1}\mathfrak{q}') \cap B = \mathfrak{q}'.
\end{align*}
[/step]