Showing a UFD which is not a PID must have a nonprincipal maximal ideal. Given that $R$ is a UFD which is not a PID, I want to show that $R$ must have a nonprincipal maximal ideal.
I tried several methods, including Zorn's lemma but didn't get anywhere. Any suggestions would be appreciated.

Case 1. Let $R$ be a non-Noetherian UFD where all of its maximal ideals are principal, then it is a PID.
Assume the contrary and let $I$ be an ideal which is maximal w.r.t being non-principal, then $I$ is a prime ideal (Look at the Theorem 1.4. for more detail.) By assumption, $I$ cannot be maximal, thus there is a maximal ideal $m=(x)$ containing $I$ properly (note that $x$ is an irreducible element.) Now, $m \subseteq I+m \subseteq R.$
If $m=I+m,$ based on assumption, any prime ideal contains a prime element (See this). Let $i \in I$ be a prime element, then $xt=i+xr$ for some $t,r \in R,$ then $i=x(t-r).$ Obviously, $i$ cannot divide $x$ so $t-r=is$ for some $s \in R.$ Therefore, $i=x(t-r)=xis$ implying that $x$ is a unit which a contradiction.
If $I+m=R$ i.e. $is+xr=1$ for $i \in I,$ and $s,r \in R.$ Now, $i \in (x),$ or $i=xt$ for some $t \in R.$ Thus, $x(ts+r)=1$ implying that $x$ is a unit element, which is again a contradiction. Hence such an $I$ does not exist and we're done.
Case 2. Let $R$ be a Noetherian UFD where all of its maximal ideals are principal, then it is a PID.
Assume not, and let $I$ be the prime ideal above contained in a principal maximal ideal $m=(x)$ Since $R$ is a Noetherian UFD then any height one prime ideal is principal, therefore, $ht(I) \geq 2$ implying that $ht(m) \geq 3,$ hence is a contradiction, by Krull's principal ideal theorem.
Addendum:
You can see another short proof below by Pete L. Clark. In fact, I was not aware of the fact that Kaplansky's theorem (as mentioned, 15.1 here) holds for all domains.
