1550s, "line of battle in close ranks," from Latin phalanx "compact body of heavily armed men in battle array," or directly from Greek phalanx (genitive phalangos) "line of battle, battle array," also "finger or toe bone," originally "round piece of wood, trunk, log," a word of unknown origin. Perhaps from PIE root *bhelg- "plank, beam" (source of Old English balca "balk;" see balk (n.)).
In anatomy, originally the whole row of finger joints, which fit together like infantry in close order. Figurative sense of "number of persons banded together in a common cause" is attested from 1600 (compare Spanish Falangist, member of a fascist organization founded in 1933).
The celebrated Macedonian phalanx was normally drawn up sixteen ranks deep, the men being clad in armor, bearing shields, and armed with swords and with spears from 21 to 24 feet long. In array the shields formed a continuous bulwark, and the ranks were placed at such intervals that five spears which were borne pointed forward and upward protected every man in the front rank. The phalanx on smooth ground, and with its flanks and rear adequately protected, was practically invincible; but it was cumbrous and slow in movement, and if once broken could only with great difficulty be reformed. [Century Dictionary]