It is easy to see that in an atomic domain (where every element factors into irreducibles), we have that all irreducibles are prime iff the domain in question is an UFD.
I think it is not true for a general (commutative, unital) ring: if we consider the ring of eventually constant sequences of integers, we can find there elements which do not decompose (in fact, any sequence which is not eventually $0,1$ or $-1$ will be like that), and irreducible elements are those which have one prime coordinate, and all others $0,1$ or $-1$.
But what about domains? Can there be a domain where all irreducibles are prime, but which is not a unique factorisation domain? Better yet, is there a domain where there are no irreducible elements?
Prime = irreducible in, e.g., GCD domains. (In fact, an integral domain is a UFD if and only if it is a GCD domain satisfying the ascending chain condition on principal ideals.) Now let's give an example of GCD domain which is not a UFD: $\mathbb Z+X\mathbb Q[X]$. (For instance, this ring doesn't have ACC on principal ideals: $(X)\subset(\dfrac{1}{2}X)\subset(\dfrac{1}{2^2}X)\subset\cdots$, so it's not a UFD.)
Edit. In the linked question the answers provide examples of rings having no irreducible elements. Instead, $\mathbb Z+X\mathbb Q[X]$ has irreducible elements: for instance, $2$ is irreducible.