This is generally not true in $ZF$ (cf. this MathOverflow question).
Assuming the axiom of choice, this becomes relatively simple.
Since $g$ is surjective, for every $b\in B$ the set $g^{-1}(b)$ is nonempty. If so we can choose $a_b$ to be such that $g(a_b) = b$ for every $b\in B$ (this can be a proper subset of $A$). The function $b\mapsto a_b$ is an injective function from $B$ into $A$.
By the Cantor-Bernstein theorem (which does not require the axiom of choice) we have that there exists a bijection $h$ as needed.
Addendum: Proof of the Cantor-Bernstein theorem using the axiom of choice
Suppose $A$ and $B$ are sets and there exists $f\colon A\to B$ injective, and $g\colon B\to A$ injective. Then there exists $h\colon A\to B$ bijective.
Proof: By the axiom of choice we can well order $A$ and $B$ as the least order type possible. So without the loss of generality we may assume $A=\alpha$ and $B=\beta$ for two ordinals.
Since two well orders are comparable in the embedding relation (i.e. $\alpha$ can be embedded into an initial segment of $\beta$, or vice versa) and in particular $\alpha\subseteq\beta$ or $\beta\subseteq\alpha$, we have if so that $f\colon\alpha\to\beta$ and $g\colon\beta\to\alpha$ are two injective functions.
Recall that $\beta$ was the least ordinal bijectible with $B$, so if $\alpha<\beta$ there is no injection from $\beta$ into $\alpha$. Therefore $g$ witnesses $\beta\le\alpha$.
The same argument holds for $\alpha$ and $A$ so $f$ witnesses $\alpha\le\beta$. Since the ordinals are linearly ordered, anti-symmetry implies $\alpha=\beta$.
The function $h$ is the composition of the well ordering functions of $A$ and $B$, that is if $w_1\colon A\to\alpha$ is the bijection of $A$ with $\alpha$, and $w_2\colon B\to\beta$ the bijection we used to well order the set $B$, define $h=w_2^{-1}\circ w_1\colon A\to B$ which is a bijection.
I'm not sure that this is the original Cantor proof, but it works, and I don't think that the proof Cantor used was too different, perhaps the use of ordinals was slightly different (back then they only used the fact that well orders are embeddable into each other nicely).