Using a simple two-group model of the private provision of public goods, this paper investigates the endogenous formation of within-group cooperation. We show that the equilibrium outcomes may result in a prisoners’ dilemma, depending on the characteristics of between-group externalities. If between-group externalities are strongly positive (negative), within-group cooperation does not occur in either group, which leads to Pareto-inferior (superior) outcomes for all agents. On the other hand, if between-group externalities are weakly positive or negative, each group chooses to cooperate within a group in providing public goods, but it may reduce utility of both group members. Our simple framework is applicable to a wide variety of socio-economic problems such as an arms race, advertising competition, transboundary pollution, and antiterrorism measures.