In the aftermath of the Battle of Ipsos and the death of Antigonos I Monophthalmos in 301 BC, the Antigonid kingdom was divided between the successors who had participated in the coalition to defeat Antigonos.  To Seleukos I Nikator went the territories of Phoinike and Koile-Syria, but when he rushed to consolidate his new lands he found Ptolemaios I Soter already there claiming them as his own.  Ptolemaios's justification was that since he had first lost them to Antigonos in 315 BC they were therefore rightly his.  Although no one can say for certain, it is possible that he had been planning this move for several months; thus explaining his absence from Ipsos for this opportunistic endeavor.  While Seleukos might have been able to seize the territories from Ptolemaios by force, he did not because of their “friendship”  -  this being originating from the asylum granted to Seleukos by the latter when he was forced from control of Babylon years earlier, as well as the aide given so that Seleukos could retake the city.  The result was that Phoinike and Koile-Syria became an especially contentious point between the two successor kingdoms that would often lead to conflicts, which became known as the Syrian Wars.  The near simultaneous ascension of the kings Antiochos III, Philippos V, and Ptolemaios IV in their respective realms in 221 BC was a harbinger for the beginning of the 4th Syrian War.
Although an invasion of Ptolemaic lands was planned in 221 BC by Antiochos immediately after gaining the kingship, the combined problems of the heavy garrisoning of southern passes and the inability of his strategoi to defeat Molon, the Satrap of Media and Viceroy of the Upper Satrapies who was now in revolt, demanded his attention.  Antiochos finally resolved the problem of Molon himself and after his began his campaign thereby initiating the 4th Syrian War to wrest control of Phoinike and Koile-Syria from the Ptolemaioi.  In 218 BC, after two attempts to break the Ptolemaic garrisons in the Marsyas Valley, Antiochos stormed the Porphyrion Pass and broke through to Koile-Syria.  Having then subdued the surrounding areas and captured several cities including Seleukeia-Pieria and Tyre, he settled his troops in winter quarters at the town of Akre.
In response to these military actions, Sosibios, the prime minister of Ptolemaios IV Philopator, assembled the Ptolemaic army, which had fallen into deterioration, and had them subjected to incredibly intense military training.  Time was bought by diplomatic stalling with Antiochos, and in June 217 BC, Ptolemaios marched his army from Alexandreia at a brisk pace for five days and encamped them southwest of the city of Raphia in modern Palestine.  Upon hearing this, Antiochos prepared his men and set out from Akre.
The forces brought to Raphia were varied.  The Antiochos brought levies from all across the empire to augment the phalanx and other Greek infantry totaling 62,000 infantry, 6,000 cavalry, and 102 Indian elephants. The Ptolemaic army was 70,000 strong in infantry, 4,700 in cavalry, and 73 in African elephants.  Of particular note were the 20,000 native Egyptians utilized in the phalanx by the Ptolemaioi, which would prove instrumental to their victory, yet would later have consequences for the Ptolemaic dynasty.
The arrangement of the troops were similar for both sides.  Framed between sand dunes and within sight of the coastline, the phalanx was in the center surrounded on both sides by troops to protect the flanks and then further by cavalry on the wings.  For both wings in front of the cavalry were the elephants supported by light troops.  However, because of Ptolemaios' vast superiority in the numbers of the phalanx and heavy infantry (in fact, save for the mercenary archers, all the infantry in army of Ptolemaios could be considered heavy infantry), Antiochos had to place his light infantry in the main battle line rather than forward so as to increase it and thus prevent flanking of the phalanx, whereas Ptolemaios could deepen his.
Antiochos and Ptolemaios themselves were opposite each other on the west side of the battlefield.  The opening moments of the battle were defined by the action on the wings and Antiochos, with his superiority in cavalry and elephants, immediately charged Ptolemaios.  Indian elephants gored their African cousins and Antiochos, having circumvented the elephants, sent the entire Ptolemaic wing into a rout and closely pursued them.  The wings on the east of the battlefield, however, were a different matter.
Despite the African elephants who were resisting to fight out of fear of their Indian counterparts, with the thousands of heavy infantry composed of Greek mercenaries, Galatians, and Thraikians, the Ptolemaioi overwhelmed the Seleukid wing, which had no heavy troops of its own – only lights.  Now the centers of the battle lines were exposed and the fight became a pushing match.
The opposing phalanxes were not equal.  The Ptolemaic phalanx closed to meet them stretching the entire distance of the remaining Seleukid line and being far deeper.  At some point during this phase of the battle, Ptolemaios returned after having somehow slipped away from the rest of the routed wing that was being pursued by Antiochos.  For a while the battle was an even match, but the Seleukid ranks, who were now nervous with their flanks exposed, began to break and flee.  The Seleukid light troops, unable to effectively fight against the phalanx, were the first, then followed by the phalangites who were fearing the return of the victorious Ptolemaic wing next to them, and finally the elite argyraspides.  The result was a decisive victory for the Ptolemaioi.
What is important to note is that though Antiochos had sent Ptolemaios and his wing into a complete rout, he did not return to complete the “hammer & anvil” tactic that was used so well by Alexander the Great; instead, he continued to chase broken troops.  Why he had done so is not explicitly known, but there are two thoughts to this.  The first is that Antiochos, in his inexperience, became caught up in the rush of the cavalry charge and forgot about his own role in battle to secure victory.  The second is that Antiochos had intended to kill Ptolemaios as soon as possible in order to bring a conclusive end to the battle sooner and possibly leave the entire Ptolemaic kingdom open to conquest as its government would collapse; however, with Ptolemaios slipping away during the chase that was no longer possible.  This second thought is the one that seems to bear more credence, but also tends to be overlooked.  It is very difficult to reign in a cavalry pursuit with a force of several thousand men; however, Antiochos was not inexperienced and battles tended to be thoroughly planned before their start.   The phalangites were probably told to hold until Antiochos returned dragging the fat body of Ptolemaios behind him.  It is also critical to consider discipline in Hellenistic armies at this time: the Seleukid phalanx could have likely resisted the return of Ptolemaic wing, which would have given time for Antiochos to return – a problem that showed itself again at Thermopylai decades later.  Regardless, if Antiochos had returned and charged the rear of the Ptolemaic phalanx rather than continue his pursuit, it is very possible that the victory could have gone to the Seleukids.  In the end, however, Antiochos was forced to retreat.
The 4th Syrian War concluded with a treaty forcing Antiochos to return Phoinike and Koile-Syria to the Ptolemaioi.  Interestingly, though Antiochos lost the war and the result was disappointing he came out of the fighting with a net gain and managed to keep control of Seleukeia-Pieria and some surrounding lands that had been lost in the 3rd Syrian War.  Like most Hellenistic treaties, it would last until the death of one of the participating kings – hence the importance of the ascension of Antiochos, Philippos, and Ptolemaios together.  Until the death of Ptolemaios, Antiochos would have to focus his attention elsewhere.

Playing the Battle:
As the player you are Antiochos III (not yet Megas) and in control of an army that stretches several kilometers in length.  In front of you and only meters away is Ptolemaios.  His death and crushing defeat being your goal.

Further Note:
Much of the credit for the victory of the Ptolemaioi belongs to the Egyptian natives who were trained and fought in the phalanx.  If not for them, the Ptolemaic army would have been 20,000 men smaller.  Ironically, the same men that allowed the Ptolemies to retain control of Phoinike and Koile-Syria would be the same men that would soon spearhead a major revolt against their Hellenistic rulers in Alexandreia.  Many Egyptians rose up and established their own kingdom with a pharaoh in Upper Egypt.  This revolt lasted until 185 BC and proved to be a point of constant irritation.  Many full time troops were constantly occupied fighting the revolt.  The absence of the Galatikoi from the Battle of Panion seventeen years later being a testament to the revolt's resilience.