Independent city states were unable to compete with Hellenistic kingdoms and were usually forced to ally themselves to one of them for defense, giving honors to Hellenistic rulers in return for protection. One example is Athens, which had been decisively defeated by Antipater in the Lamian war (323–322 BC) and had its port in the Piraeus garrisoned by Macedonian troops who supported a conservative oligarchy. After Demetrius Poliorcetes captured Athens in 307 BC and restored the democracy, the Athenians honored him and his father Antigonus by placing gold statues of them on the agora and granting them the title of king. Athens later allied itself to Ptolemaic Egypt to throw off Macedonian rule, eventually setting up a religious cult for the Ptolemaic kings and naming one of the city's phyles in honour of Ptolemy for his aid against Macedon. In spite of the Ptolemaic monies and fleets backing their endeavors, Athens and Sparta were defeated by Antigonus II during the Chremonidean War (267–261 BC). Athens was then occupied by Macedonian troops, and run by Macedonian officials.