Aggregation and coexistence. I. Theory and analysis