Proof (irreducible iff prime in UFD)
"$\Leftarrow$" is true in all rings.
Suppose $p\in R$ is irreducible and $p\mid xy$. Then say $xy = pz$ for some $z\in R$. Expand $x,y,z$ as their factorisations to see $$ \begin{align*} \underbrace{(q_1 \ldots q_n)}_{x}\,\underbrace{(r_1 \ldots r_m)}_{y} = p \underbrace{(s_1 \ldots s_k)}_{z} \end{align*} $$ where $q_i, r_i, s_i$ are irreducibles. Then by uniqueness of factorisations, $p$ is associate with one of the $q_i$'s or $r_i$'s, and thus $p\mid q_i \mid x$ or $p\mid r_i\mid y$.