Feedbacks between land carbon pools and climate provide one of the largest sources of uncertainty in our predictions of global climate. Estimates of the sensitivity of the terrestrial carbon budget to climate anomalies in the tropics and the identification of the mechanisms responsible for feedback effects remain uncertain. The Amazon basin stores a vast amount of carbon, and has experienced increasingly higher temperatures and more frequent floods and droughts over the past two decades. Here we report seasonal and annual carbon balances across the Amazon basin, based on carbon dioxide and carbon monoxide measurements for the anomalously dry and wet years 2010 and 2011, respectively. We find that the Amazon basin lost 0.48 ± 0.18 petagrams of carbon per year (Pg C yr−1) during the dry year but was carbon neutral (0.06 ± 0.1 Pg C yr−1) during the wet year. Taking into account carbon losses from fire by using carbon monoxide measurements, we derived the basin net biome exchange (that is, the carbon flux between the non-burned forest and the atmosphere) revealing that during the dry year, vegetation was carbon neutral. During the wet year, vegetation was a net carbon sink of 0.25 ± 0.14 Pg C yr−1, which is roughly consistent with the mean long-term intact-forest biomass sink of 0.39 ± 0.10 Pg C yr−1 previously estimated from forest censuses. Observations from Amazonian forest plots suggest the suppression of photosynthesis during drought as the primary cause for the 2010 sink neutralization. Overall, our results suggest that moisture has an important role in determining the Amazonian carbon balance. If the recent trend of increasing precipitation extremes persists6, the Amazon may become an increasing carbon source as a result of both emissions from fires and the suppression of net biome exchange by drought.