A long-standing question in community ecology is whether food webs are organized in compartments, where species within the same compartment interact frequently among themselves, but show fewer interactions with species from other compartments. Finding evidence for this community organization is important since compartmentalization may strongly affect food web robustness to perturbation. However, few studies have found unequivocal evidence of compartments, and none has quantified the suite of mechanisms generating such a structure. Here, we combine computational tools from the physics of complex networks with phylogenetic statistical methods to show that a large marine food web is organized in compartments, and that body size, phylogeny, and spatial structure are jointly associated with such a compartmentalized structure. Sharks account for the majority of predatory interactions within their compartments. Phylogenetically closely related shark species tend to occupy different compartments and have divergent trophic levels, suggesting that competition may play an important role structuring some of these compartments. Current overfishing of sharks has the potential to change the structural properties, which might eventually affect the stability of the food web.