Irreducibles are prime in a UFD
The proof given above is probably the standard one to show that a factorial domain is an AP-domain. But there is another proof using the following application: for an irreducible $p\in D$, let's define $e_p\colon D\setminus \{0\}\rightarrow \Bbb{N}$ given by $a\mapsto e_p(a)=\#$ of times that $p$ or its associates appear in the irreducible factorization of $a$.
We notice that because $D$ is factorial the application given above it's well defined. Moreover, if $a\in D^{\times}$, then $e_p(a)=0$ for every irreducible $p$, and if $a\in D\setminus{D^{\times}_0}$, then $e_p(a)=0$ iff $p\not\mid a$. Equivalently, $e_p(a)>0$ iff $p\mid a$.
We have the following:
Lemma: Let $D$ be a factorial domain and $a,b\in D\setminus \{0\}$. Then $$e_p(ab)=e_p(a)+e_p(b)$$ for every irreducible $p\in D$.
Proof: As $D$ is factorial, we can write $a=p^{e_p(a)}\ldots $ and $b=p^{e_p(b)}\ldots $, then $$ab=(p^{e_p(a)}\ldots)(p^{e_p(b)}\ldots)=p^{e_p(a)+e_p(b)}\ldots $$ Hence, $e_p(ab)=e_p(a)+e_p(b)$.
Now we're going to prove that if $D$ is factorial, then $D$ is an AP-domain. Let $p$ be an irreducible element in $D$ and let $a,b\in D$ such that $p\mid ab$. If $ab=0$, then $a=0$ or $b=0$, so in this case clearly $p\mid a$ or $p\mid b$. If $ab\neq 0$, since $p\mid ab$ we have $e_p(ab)>0$, so by the above lemma we find $$e_p(ab)=e_p(a)+e_p(b)>0.$$ Therefore we deduce that necessarily $e_p(a)>0$ or $e_p(b)>0$, i.e., $p\mid a$ or $p\mid b$. Hence, $p$ is prime.
As a remark, this kind of ideas applied to $\Bbb{Z}$ can be found in the first pages of the book "A Classical Introduction to Modern Number Theory" by K. Ireland and M. Rosen.
It's trivial to show that primes are irreducible. So, assume that $a$ is an irreducible in a UFD (Unique Factorization Domain) $R$ and that $a \mid bc$ in $R$. We must show that $a \mid b$ or $a \mid c$. Since $a\mid bc$, there is an element $d$ in $R$ such that $bc=ad$. Now replace $b,c$ and $d$ by their factorizations as a product of irreducibles and use uniqueness.