Yes this is true.

Your condition means that there is a birational map $f: M\dashrightarrow \mathbb{P}^n$ which is isomorphic in codimension $1$. This gives an isomorphism $f_*: \text{Cl}(M) \to \text{Cl}(\mathbb{P}^n)$ between class groups of Weil divisors.

In particular, the Picard rank of $M$ is $1$. This implies that $f$ is actually an isomorphism. Indeed, for an ample divisor $D$ on $M$, $f_*D$ is ample on $\mathbb{P}^n$. Moreover, since $f$ is isomorphic in codimension $1$, we have identifications between global sections: $H^0(M, mD)\simeq H^0(\mathbb{P}^n, mf_*D)$. So there is an isomorphism between the graded algebras
$$\bigoplus_{m\geq 0}H^0(M, mD)\simeq \bigoplus_{m\geq 0}H^0(\mathbb{P}^n, mf_*D).$$ Taking Proj of those graded algebras, we get $M\simeq \mathbb{P}^n$ which is induced by $f$.

This argument still works if you replace $\mathbb{P}^n$ by a $\mathbb{Q}$-factorial normal variety of Picard number $1$, and replace $M$ by a $\mathbb{Q}$-factorial normal variety.