Substantive research in the Social Sciences regularly investigates signed networks, where edges between actors are either positive or negative. For instance, schoolchildren can be friends or rivals, just as countries can cooperate or fight each other. This research often builds on structural balance theory, one of the earliest and most prominent network theories, making signed networks one of the most frequently studied matters in social network analysis. While the theorization and description of signed networks have thus made significant progress, the inferential study of tie formation within them remains limited in the absence of appropriate statistical models. In this paper we fill this gap by proposing the Signed Exponential Random Graph Model (SERGM), extending the well-known Exponential Random Graph Model (ERGM) to networks where ties are not binary but negative or positive if a tie exists. Since most networks are dynamically evolving systems, we specify the model for both crosssectional and dynamic networks. Based on structural hypotheses derived from structural balance theory, we formulate interpretable signed network statistics, capturing dynamics such as "the enemy of my enemy is my friend". In our empirical application, we use the SERGM to analyze cooperation and conflict between countries within the international state system.