Using a simple two-group model of the private provision of public goods, this paper investigates how endogenous formation of within-group cooperation is affected by different types and degrees of between-group interactions. We show that when between-group interactions are of the same directions and weak (strong), within-group cooperation for providing public goods will (will not) occur in each group for strategic reasons. On the other hand, when between-group interactions are of the opposite directions or unidirectional, within-group cooperation will necessarily occur. In addition, endogenous formation of cooperation is independent of absolute (individual) levels of income as well as income distribution between agents, which corresponds to an extended version of Warr's neutrality theorem. We also show whether endogenous formation of within-group cooperation is beneficial or harmful to each group crucially depends on the degree of between-group interactions. The variation in the interaction degree leads to three different types of games concerning welfare consequences: the Prisoners' Dilemma, Coordination Game, and Invisible Hand.