[guided]Suppose $f \in R[x]$ is a nonzero non-unit with two factorisations into irreducibles:
\begin{align*}
f = a_1 \cdots a_r \cdot p_1 \cdots p_s = b_1 \cdots b_t \cdot q_1 \cdots q_u,
\end{align*}
where $a_i, b_j \in R$ are irreducible in $R$ and $p_k, q_l \in R[x]$ are irreducible polynomials of degree $\ge 1$. We must show that $r = t$, $s = u$, and the factors agree up to reordering and units.
**Irreducible polynomials of positive degree are primitive.** We first verify that each $p_k$ is primitive. If $c(p_k)$ were a non-unit $d \in R$, then $p_k = d \cdot (p_k / d)$ would be a non-trivial factorisation in $R[x]$: $d$ is a non-unit, and $p_k / d$ is a non-unit since $\deg(p_k / d) = \deg(p_k) \ge 1$. This contradicts the irreducibility of $p_k$. So $c(p_k) \sim 1_R$ for each $k$, and similarly $c(q_l) \sim 1_R$ for each $l$.
**Uniqueness of the constant factors.** By the multiplicativity of content, $c(p_1 \cdots p_s) \sim c(p_1) \cdots c(p_s) \sim 1_R$ (each factor is primitive, so the product is primitive). Taking contents of the full factorisation: $c(f) \sim a_1 \cdots a_r \cdot c(p_1 \cdots p_s) \sim a_1 \cdots a_r$. Similarly, $c(f) \sim b_1 \cdots b_t$. Since $R$ is a UFD, the two factorisations of $c(f)$ into irreducibles in $R$ agree up to reordering and units: $r = t$ and $a_i \sim b_i$ after reindexing.
**Uniqueness of the polynomial factors.** Dividing both sides by $c(f)$ (a nonzero element of $R$, hence a non-zero-divisor), we obtain $p_1 \cdots p_s = v \cdot q_1 \cdots q_u$ for some unit $v \in R^\times$. We pass to $F[x]$. By [Gauss's Lemma](/theorems/858), a primitive polynomial in $R[x]$ is irreducible in $R[x]$ if and only if it is irreducible in $F[x]$. Since each $p_k$ is primitive and irreducible in $R[x]$, each $p_k$ is irreducible in $F[x]$. The same reasoning shows each $q_l$ is irreducible in $F[x]$. Since $F[x]$ is a UFD, uniqueness of factorisation in $F[x]$ gives $s = u$ and, after reordering, $p_k = \alpha_k q_k$ for some $\alpha_k \in F^\times$.
**The scalars $\alpha_k$ are units of $R$.** Write $\alpha_k = a/b$ with $a, b \in R \setminus \{0\}$ and $\gcd(a, b) \sim 1_R$. Then $b \cdot p_k = a \cdot q_k$ in $R[x]$. Taking contents on both sides: $c(b \cdot p_k) = b \cdot c(p_k) \sim b$ (since $p_k$ is primitive), and $c(a \cdot q_k) = a \cdot c(q_k) \sim a$ (since $q_k$ is primitive). Therefore $b \sim a$. Combined with $\gcd(a, b) \sim 1_R$, this forces both $a$ and $b$ to be units of $R$, so $\alpha_k = a/b \in R^\times$.
Therefore $p_k \sim q_k$ in $R[x]$ for each $k$, and the two factorisations agree up to reordering and multiplication by units. This completes the proof that $R[x]$ is a UFD.[/guided]