We propose Hyb-CCEA, a cooperative coevolutionary algorithm for the evolution of genetically heterogeneous multiagent teams. The proposed approach extends the cooperative coevolution architecture with operators that put the number of coevolving populations under evolutionary control. Populations are dynamically merged based on behavioral similarity, thus decreasing team heterogeneity, and stochastic population splits are used to explore increased team heterogeneity. Hyb-CCEA is capable of converging to suitable team compositions for the given task, be it a completely homogeneous team where all agents share the same control logic, a heterogeneous team where each agent has distinct control logic, or a partially heterogeneous team. By placing both team composition and agent controllers under evolutionary control, Hyb-CCEA can be applied to domains for which the experimenter has limited or no knowledge about possible solutions. We study Hyb-CCEA extensively in an abstract domain, and conduct a series of validation experiments with four simulated multirobot tasks: two multirover foraging tasks and two robotic soccer tasks. The results show that Hyb-CCEA takes advantage of partial heterogeneity and frequently outperforms the standard cooperative coevolution approach, both in terms of fitness scores achieved and number of evaluations needed to evolve solutions.