In the 1st Punic War Rome took the fight to Carthage literally and landed a force under the general Regulus in North Africa. Regulus defeated a Carthaginian force at Aspis (255 BCE) and then besieged the city of Adys.
This caused panic at Carthage. What were they to do? Well, the policy of recruiting mercenaries was to bear fruit. Step forward a Spartan named Xanthippus.
Spartan know how.
Xanthippus had arrived with other Greek mercenaries and was quick to point out exactly what the problems were with the troops. This ranged to simple drills through to how they were best used on the battlefield. Initially Xanthippus was put in charge of drilling the troops and he made an immediate impact. His men admired him and those watching saw moves and drills in places which had been sloppy at best.
Battle of Tunisia, 255 BCE.
Carthage was able to put this newly drilled army into the field and this clashed with Regulus and his Roman force at the Battle of Tunis (also known as the Battle of the Bagradas River). Prior to the battle the Carthaginians had given Xanthippus nominal control of the army. The Carthaginian force numbered 16,000 and the Romans around the same. What was different were the cavalry, Carthage fielded more and had elephants.
It was a tightly contested affair, however, the Carthaginian cavalry were able to box the infantry in. In a sense this anticipated the effectiveness of cavalry which Rome would experience under Hannibal. The elephants, though never a reliable unit, were able to break the Roman formation and the drilled Carthaginians phalanx was decisive. The Roman force was soundly beaten.
Aftermath.
Xanthippus didn’t stay long. It’s possible he had a glimpse of the toxicity of Carthaginian politics, successful generals were soon envied. Even worse he was a Greek. Perhaps understanding that he would surely be made a scapegoat at some point Xanthippus left Carthage.
The fate of Regulus is debated, a later story has him returning to Rome having given his word to return to Carthage as a prisoner. It’s a remarkably unsubtle piece of Roman propaganda. More likely is that he died in captivity.
But for a moment we did have a version of that “what if Sparta fought Rome?” question, well, sort of.