A species is often defined as a group of organisms capable of interbreeding and producing fertile offspring. Therefore, for two animals to be able to interbreed, they are by definition the same species.
There are, however, animals that are often thought of as separate species that can interbreed to produce either fertile or sterile offspring. Examples would be horses with donkeys, dogs with wolves and tigers with lions.
Another example would be species in the Vitis genus, grapes. They can interbreed, despite being considered separate species.
Animals can mate (perform intercourse) so long as the anatomy fits. Whether the female becomes pregnant is down to the genetic distance between the two animals. As mentioned above, some animals can mate and produce offspring. However, the offspring may not be able to produce offspring of their own and thus, are infertile. To produce offspring, sterile or otherwise, the animals are generally closely related genetically. Lions and Tigers being a good example. It is extremely unlikely that a Blue Whale and a Leafcutter Ant will produce offspring, for various reasons.
One of the most common barriers between very similar species is polyploidy, a change in the number of chromosomes. This is a common way in which plants start new species.