The way I understand it is that to defeat a phalanx you outmaneuver it. This was very difficult for the Persians to do in Greece due to the mountainous terrain, but in the large flat plains of the interior of the Empire (Mesopotamia specifically) how did Alexander now have his steamrolling phalanxes destroyed by the more maneuverable Persian troops?
They very nearly did. At Gaugamela Alexander's Infantry was struggling against the Persians, they were signalling for help at the point he made his famous charge and after Darius quit the field Alexander had to let him go so he could turn around and move back to assist his infantry. This was where the Greeks took most of their casualties at Gaugamela and Alexander himself was injured in this part of the action. This was probably the closest point on the campaign Alexander came to failure.
I don't believe that Phillip II of Macedon gets enough credit for instating the military reforms that would make Alexander's conquests possible.
Among them:
Modifying the phalanx to make it neigh impenetrable. Theban formation had contained 8 rows; Philip doubled this to sixteen. Phillip's hoplites had a re-designed shield that was to be worn on the shoulder, which freed up both hands for combat. This was really important, as he lengthened the Thebean spear into the Sarissa, a 21 foot long pike! The first 5 ranks would point their spears forward, creating a hedgehog effect. The remaining ranks would hold the Sarissa at a 45 degree angle, providing a measure of coverage against incoming arrows and javelins.
Phillip realized the big problem with a bunch of heavily armed and armored dudes walking in a big rectangular formation. It's easy to get outflanked that way. Phillip added skirmishers who were largely armed with bows and javelins (although sometimes slings if I remember correctly) whose job it was to harass enemy troops and protect the flanks of the heavy infantry Hoplites.
He also added heavy and light cavalry into the Macedonian military. Largely drawn from Macedonian nobles (you know, the people that could actually afford horses) this gave a measure of mobility as a 'shock force' that previously hadn't been seen in warfare in the Grecian world.
While the first two reforms had existed in Asiatic armies previously (most notably the Persians) this one is a dozy. Phillip's greatest innovation was putting siege engines such as the Ballistae and the Catapult on to the field of battle as artillery support.
He worked on developing logistical services to ensure that transporting all these warriors and their equipment would be done in a timely manner.
Finally, he likely had the most rigorous military training in the Grecian world outside of Sparta.
This military organization and preparedness was what allowed Phillip II to conquer the squabbling Grecian city-states who were weakened from their inner conflicts. Without the reforms of Phillip II, it is highly unlikely that Alexander would have been able to conquer his way out of a wet paper bag.