Rotman's "An Introduction to the Theory of Groups" contains the above result as Theorem 11.3. However, I failed to pickup a step of the proof. It goes something like this:
($F \simeq G \implies \operatorname{rank}(F) = \operatorname{rank}(G)$)
Let $X$ be a basis of $F$ and let $Y$ be a basis of $G$. Since $F \simeq G$, then $F/F' \simeq G/G'$, where $F'$ denotes the commutator subgroup. By a previous result, $F/F'$ is a free abelian group of basis $\overline{X} = \{xF'\mid x \in X\}$, and, by a previous result on free abelian groups, $|\overline{X}| = |\overline{Y}|$. As $\mathbf{|X| = |\overline{X}|}$, we have the result.
The part in bold is where I couldn't understand. In principle, based on Rotman's definition of a free group with basis $X$, I couldn't see a reason why, if $xF' = \tilde{x}F'$, then $x = \tilde{x}$. In fact, even if I could, at this point, use that $F$ is generated by $X$, I don't think I'd be able to prove this tiny part of the result...
Could anyone give me any hints as per how to procede?
Thanks in advance!
PS: Rotman's definition of a free group
Def: A group $F$ is called free with basis $\mathbf{X}$ $\iff$ for every group $G$ and for every function $f: X \to G$, there exists one, and only one, homomorphism $\phi: F \to G$ that extends $f$.
As Derek Holt points out, this boils down to showing that $xy^{-1}$ is not in the commutator subgroup $F' \leq F$ when $x\neq y$.
The easiest way to see this is to pick any abelian group $C$ with two distinct elements $a,b$ (the cyclic group of order $2$ will do). Because $F$ is free on $X$, there exists a homomorphism $f:F\to C$ with $f(x)=a$ and $f(y)=b$. In particular, $xy^{-1} \notin \ker{f}$.
But, since $C$ is abelian, $F'\subset \ker{f}$.