It's possible because these two species are very closely related, so their DNA is (I presume but have no hard numbers) very similar.
There are plenty of examples of cross-species breeding (aka hybridization)-- especially with plants. Other examples involving animals are zebra + horse and camel + llama. As Bignate said, in almost all cases the offspring are sterile, this is because homologous chromosomes (that is, one from each parent) fail to pair up and segregate properly during meiosis (the process that forms sperm/egg). Human intervention was also required to induce mating in every case (AFAIK).
The plasticity of interspecies boundaries is often used by creationists in a lame attempt to advance their own classification system based on "kinds" (incidentally, I have never heard this term defined, if anyone can so enlighten me please do so).
how far can you stretch sperm/egg compatibility between species?
Nobody knows for certain becuase the limits have never been systematically pushed AFAIK, but you definitely won't see a human fly any time soon.


It's not really a question of sex organ anatomy or the gametes themselves anyway, but rather the similarity of actual proteins inside those cells (which in turn depends up the DNA). Some proteins are remarkably conserved among species but others are not and require complementary proteins that they can properly bind to--they will not "fit" together if the two cross-breeding species are too different. Plus, some genes are unique to individual species.
A more significant issue is that many species have different numbers of chromosomes (large pieces of DNA)--for example chimpanzees have 48 and humans have 46, so if you were thinking of crossing them you would need to ensure that one copy of the chimpanzee's extra chromosome was enough for life (aka haplosufficiency), because the resulting offspring would have 47 chsms. You could try ape + chimpanzee since both have 48 chsms, but they are less closely related than humans and chimps.