Let $M$ be a commutative monoid for which the cancellation laws hold. Given $a,b\in M$, show that if $a$ and $b$ are relatively prime then $\gcd(a,b)=\mathcal{U}(M)$, where $\mathcal{U}(M)$ is the group of units of the monoid $M$.
I find the analogous proof for integers and integral domains everywhere, but I need to prove this for monoids. Thanks in advance.