The use of war elephants dates back at least to the fourth century B.C., when Indian kings took Asian elephants into battle. The practice soon spread west to the Persian Empire and then northern Africa, where African elephants were put to military use. There’s only one known case, though, of an African elephant-Asian elephant matchup, at the Battle of Raphia near Gaza on June 22, 217 B.C. The battle, over the sovereignty of Syria, matched the forces of Ptolemy IV, pharaoh of Egypt, against those of Antiochus III, a Greek king whose reign stretched into western Asia.
I wonder what kind of training was involved in mounted elephant combat, both elephant mounted to ground combat and also in engaging an enemy who was also mounted on an elephant. I'd imagine that using a pike against a trained opponent is already pretty hard, much less using one to kill said opponent.