Eddy-covariance measurements of net ecosystem carbon exchange (NEE) were carried out above a grazed Mediterranean C3/C4 grassland in southern Portugal, during two hydrological years, 2004–2005 and 2005–2006, of contrasting rainfall. Here, we examine the seasonal and interannual variation in NEE and its major components, gross primary production (GPP) and ecosystem respiration (Reco), in terms of the relevant biophysical controls. The first hydrological year was dry, with total precipitation 45% below the long-term mean (669 mm) and the second was normal, with total precipitation only 12% above the long-term mean. The drought conditions during the winter and early spring of the dry year limited grass production and the leaf area index (LAI) was very low. Hence, during the peak of the growth period, the maximum daily rate of NEE and the light-use and water-use efficiencies were approximately half of those observed in the normal year. In the summer of 2006, the warm-season C4 grass, Cynodon dactylon L., exerted an evident positive effect on NEE by converting the ecosystem into a carbon sink after strong rain events and extending the carbon sequestration for several days, after the end of senescence of the C3 grasses. On an annual basis, the GPP and NEE were 524 and 49 g C m−2, respectively, for the dry year, and 1261 and −190 g C m−2 for the normal year. Therefore, the grassland was a moderate net source of carbon to the atmosphere, in the dry year, and a considerable net carbon sink, in the normal year. In these 2 years of experiment the total amount of precipitation was the main factor determining the interannual variation in NEE. In terms of relevant controls, GPP and NEE were strongly related to incident photosynthetic photon flux density on short-term time scales. Changes in LAI explained 84% and 77% of the variation found in GPP and NEE, respectively. Variations in Reco were mainly controlled by canopy photosynthesis. After each grazing event, the reduction in LAI affected negatively the NEE.