In 215 BC Philip, with his eye on Illyria, formed an alliance with Rome's enemy Hannibal of Carthage, which led to Roman alliances with the Achaean League, Rhodes and Pergamum. The First Macedonian War broke out in 212 BC, and ended inconclusively in 205 BC. Philip continued to wage war against Pergamon and Rhodes for control of the Aegean (204-200 BCE) and ignored Roman demands for non-intervention in Greece by invading Attica. In 198 BC, during the Second Macedonian War Philip was decisively defeated at Cynoscephalae by the Roman proconsul Titus Quinctius Flamininus and Macedon lost all its territories in Greece proper. Greece was now thoroughly brought into the Roman sphere of influence, though it retained nominal autonomy. The end of Antigonid Macedon came when Philip V's son, Perseus, was defeated and captured by the Romans in the Third Macedonian War (171–168 BCE).