The manual processing of eight species of leaf was investigated in the M-group chimpanzees of Mahale Mountains National Park, Tanzania. Leaf species varied in the extent to which physical defences made consumption difficult. In all, 96 distinct techniques for leaf processing were identified, but two species with defended leaves (Ficus asperifolia and F. exasperata) required 2.5 as many techniques as did any of the six undefended species. Moreover, chimpanzees made more multiple leaf detachments, and made more subsequent modifications of the leaves, when dealing with the leaves of these two Ficus species, compared with the undefended leaf species. This greater complexity was associated with evidence of flexible, hierarchical organization of the process: iteration of modules consisting of several processing elements, facultative omission of modules, or substitutions of alternative modules. Comparison with data from mountain gorillas is made, and is consistent with similar cognitive architecture in the two species. We consider that, not only is hierarchical organization currently associated with mechanical difficulty in food processing, but that over evolutionary time-scales difficulties in food processing may have selected for cognitive advance.