2 added 259 characters in body

If and only if the Picard group is trivial. (Similar to in algebraic number theory).

Proof: Suppose $R$ is a UFD. Then every codimension 1 prime ideal is principal. Since these generate the divisor group, every divisor is principal. Suppose $R$ is not a UFD. Take an irreducible element that is not prime. This element must be contained in a codimension 1 prime ideal that is not principal (I think?). This would be a non-principal divisor.

There may be some assumptions I'm forgetting on the divisor group.

If you think the Picard group is geometric enough, we are done. (In particular, there are topological obstructions to having trivial Picard group.)

EDIT: Francois Brunault points out that these arguments are about the Weil divisor class group, not the Picard group. These concepts agree on nonsingular varieties but differ on singular ones. Sadly, the Weil group is less geometric than the Picard group.

1

If and only if the Picard group is trivial. (Similar to in algebraic number theory).

Proof: Suppose $R$ is a UFD. Then every codimension 1 prime ideal is principal. Since these generate the divisor group, every divisor is principal. Suppose $R$ is not a UFD. Take an irreducible element that is not prime. This element must be contained in a codimension 1 prime ideal that is not principal (I think?). This would be a non-principal divisor.

There may be some assumptions I'm forgetting on the divisor group.

If you think the Picard group is geometric enough, we are done. (In particular, there are topological obstructions to having trivial Picard group.)