[proofplan]
We show that any ideal containing $\mathfrak{p}$ must equal either $\mathfrak{p}$ or $R$. Since $R$ is a PID, every ideal is principal, so we write $\mathfrak{p} = (p)$ and any ideal containing $\mathfrak{p}$ as $(d)$. The containment $(p) \subset (d)$ forces $d \mid p$. Since $p$ is irreducible (being a generator of a nonzero prime ideal in a PID), $d$ is either a unit or an associate of $p$, which gives $(d) = R$ or $(d) = (p)$.
[/proofplan]
[step:Write $\mathfrak{p} = (p)$ for a nonzero element $p \in R$ and show $p$ is irreducible]
Since $R$ is a principal ideal domain, the ideal $\mathfrak{p}$ is principal. Write $\mathfrak{p} = (p)$ for some $p \in R$. Because $\mathfrak{p}$ is nonzero, $p \neq 0_R$. Because $\mathfrak{p} \neq R$ (prime ideals are proper), $p \notin R^\times$.
We verify that $p$ is [irreducible](/page/Irreducible%20Element). Suppose $p = ab$ for some $a, b \in R$. Then $ab \in (p) = \mathfrak{p}$, and since $\mathfrak{p}$ is prime, either $a \in \mathfrak{p}$ or $b \in \mathfrak{p}$.
**Case 1:** $a \in \mathfrak{p} = (p)$. Then $a = pc$ for some $c \in R$, so $p = ab = pcb$. Since $R$ is an integral domain and $p \neq 0_R$, we cancel $p$ to obtain $1_R = cb$, hence $b \in R^\times$.
**Case 2:** $b \in \mathfrak{p} = (p)$. By the identical argument with the roles of $a$ and $b$ exchanged, $a \in R^\times$.
In either case, one of $a, b$ is a unit. Therefore $p$ is irreducible.
[guided]
We need to show that $p$ is irreducible because irreducibility is the key property that will force the conclusion in the next step. In a general integral domain, prime elements are always irreducible, and that is exactly what we verify here.
Since $R$ is a principal ideal domain, every ideal of $R$ is of the form $(a)$ for some $a \in R$. In particular, $\mathfrak{p} = (p)$ for some $p \in R$. Because $\mathfrak{p}$ is nonzero, we have $p \neq 0_R$. Because $\mathfrak{p}$ is a prime ideal, it is proper ($\mathfrak{p} \neq R$), which means $p \notin R^\times$ (if $p$ were a unit, then $(p) = R$).
We claim $p$ is [irreducible](/page/Irreducible%20Element). Suppose $p = ab$ for some $a, b \in R$. Then $ab = p \in (p) = \mathfrak{p}$. By the definition of a [prime ideal](/page/Prime%20Ideal), $\mathfrak{p}$ being prime means: whenever a product $ab \in \mathfrak{p}$, at least one factor lies in $\mathfrak{p}$. So either $a \in \mathfrak{p}$ or $b \in \mathfrak{p}$.
Suppose $a \in \mathfrak{p} = (p)$. Then $a = pc$ for some $c \in R$. Substituting into $p = ab$ gives $p = pcb$, i.e., $p(1_R - cb) = 0_R$. Since $R$ is an integral domain and $p \neq 0_R$, we conclude $cb = 1_R$, so $b \in R^\times$. The case $b \in \mathfrak{p}$ is symmetric and yields $a \in R^\times$.
Therefore, in any factorisation $p = ab$, at least one of $a, b$ is a unit, which is precisely the definition of irreducibility.
[/guided]
[/step]
[step:Show that any ideal properly containing $(p)$ must equal $R$]
Suppose $I \trianglelefteq R$ satisfies $(p) \subset I \subset R$. Since $R$ is a PID, write $I = (d)$ for some $d \in R$. The containment $(p) \subset (d)$ means $p \in (d)$, so $p = dr$ for some $r \in R$. This is a factorisation of $p$ in $R$.
Since $p$ is irreducible (established in the previous step), either $d \in R^\times$ or $r \in R^\times$.
If $d \in R^\times$, then $(d) = R$, so $I = R$.
If $r \in R^\times$, then $d = pr^{-1}$, so $d \in (p)$ and hence $(d) \subset (p)$. Combined with $(p) \subset (d)$, this gives $(d) = (p)$, i.e., $I = \mathfrak{p}$.
Therefore the only ideals containing $\mathfrak{p}$ are $\mathfrak{p}$ itself and $R$. By the [definition of a maximal ideal](/page/Maximal%20Ideal), $\mathfrak{p}$ is maximal.
[guided]
Now we use irreducibility to establish maximality. Recall that an ideal $\mathfrak{p}$ is [maximal](/page/Maximal%20Ideal) if $\mathfrak{p} \neq R$ and there is no ideal $I$ with $\mathfrak{p} \subsetneq I \subsetneq R$. We already know $\mathfrak{p} \neq R$ (it is prime, hence proper), so we must show that no ideal sits strictly between $\mathfrak{p}$ and $R$.
Let $I \trianglelefteq R$ with $(p) \subset I \subset R$. Since $R$ is a PID, there exists $d \in R$ with $I = (d)$. The inclusion $(p) \subset (d)$ means $p \in (d)$, so there exists $r \in R$ with $p = dr$. This is a factorisation of the irreducible element $p$.
By irreducibility of $p$, exactly one of the following holds:
**Case 1: $d \in R^\times$.** Then $(d) = R$, so $I = R$. This means $I$ is not a proper ideal -- it does not sit strictly between $\mathfrak{p}$ and $R$.
**Case 2: $r \in R^\times$.** Then $d = pr^{-1} \in (p)$, so every element of $(d)$ lies in $(p)$: for any $dx \in (d)$, we have $dx = pr^{-1}x \in (p)$. Thus $(d) \subset (p)$. Combined with $(p) \subset (d)$, we get $(d) = (p)$, i.e., $I = \mathfrak{p}$.
In both cases, $I$ equals either $\mathfrak{p}$ or $R$. Since no ideal sits strictly between $\mathfrak{p}$ and $R$, the ideal $\mathfrak{p}$ is maximal by definition.
[/guided]
[/step]