Groundwater service markets are important and dynamic institutions that provide water to a wide range of farmers in many regions. However, these institutions represent arenas of complex and often antagonistic relations, which determine which farmers gain access to water and how. This study analyses the emergence and functioning of groundwater service markets from a historical perspective to advance the understanding of the role of social power games in shaping these institutions. The study was conducted in the Sidi Okba oasis in the Algerian Sahara, where over recent decades, four (in)formal, often overlapping, groundwater service markets have emerged. These markets were shaped progressively by socio-ethnic antagonism, state intervention and economic competition between water sellers. By continuously adjusting these institutions, the highly diverse irrigation community prevented the emergence of a monopoly in groundwater sales and maintained the balance of power between water sellers and buyers by countering possible control of groundwater access by a single socio-ethnic or economic group. The demonstrated ability of the irrigation community to craft rules to ensure these groundwater service markets function should encourage public actors to mobilize this capacity to deal with the drop in water tables, which is one adverse outcome of the 'success' of these markets.