Irreducibles are prime in a UFD 
Any irreducible element of a factorial ring $D$ is a prime element of
  $D$.

Proof. Let $p$ be an arbitrary irreducible element of $ D$. Thus $ p$
 is a non-unit. If $ ab \in (p)\smallsetminus\{0\}$, then $ ab = cp$
 with $ c \in D$. We write $ a,\,b,\,c$ as products of irreducibles:
 $$\displaystyle a \;=\; p_1\cdots p_l, \quad b \;=\; q_1\cdots q_m,
 \quad c \;=\; r_1\cdots r_n.$$ Here, one of those first two products may
 be empty, i.e., it may be a unit. We have $$\displaystyle p_1\cdots
 p_l\,q_1\cdots q_m \;=\; r_1\cdots r_n\,p\tag{1}$$           

Due to the uniqueness of prime factorization, every factor $ r_k$ is
  an associate of certain of the $l+m$ irreducibles on the left
  hand side of $(1)$. Accordingly, $p$ has to be an associate of one of
  the $ p_i$'s or $ q_j$'s. It means that either $ a \in (p)$ or $ b \in
 (p)$. Thus, $ (p)$ is a prime ideal of $ D$, and its generator must be
  a prime element.

It may be too simple, but why $ a \in (p)$ instead of $p_1 \in (p)$?
Is it because $p$ has to be an associate of one of the $ p_i$'s or $ q_j$'s? Let's say $p_2$ is an associate of $p$. So, $p_2=pw$, $w\in R$. Since $a=p_1p_2\cdots p_l$ then $a=p_1pwp_3\cdots p_l$ and $a=p(p_1p_3\cdots p_lw)$, $p_1p_3\cdots p_lw \in R$ so $a$ is divisible by $p$ hence $a\in (p)$?
 A: 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.
A: 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.
