Abstract. Coastal flooding and sea level rise (SLR) will affect farmers in coastal areas, as increasing salinity levels will reduce crop yields, leading to a loss of net annual income for farming communities. In response, farmers can take various actions. To assess such responses under SLR, we applied an agent-based model (ABM) to simulate the adaptation and migration decisions of farmers in coastal Mozambique. The ABM is coupled with a salinization module to simulate the relationship between soil salinity and SLR. The decision rules in the model (DYNAMO-M) are based on the economic theory of subjective expected utility. This theory posits that households can maximize their welfare by deciding whether to (a) stay and face losses from salinization and flooding, (b) stay and adapt (e.g. switching to salt-tolerant crops and enhancing physical resilience such as elevating houses), or (c) migrate to safer inland areas. The results show that coastal farmers in Mozambique face total losses of up to USD 12.5 million yr−1 from salt intrusion and up to USD 1200 million yr−1 from flooding of buildings (RCP8.5 in the year 2080). Sorghum farmers may experience little damage from salt intrusion, while rice farmers may experience losses of up to USD 4000 yr−1. We show that medium-sized farmers (1–5 ha) are most at risk. This is because their farm size means that adaptation costs are substantial, while their incomes are too low to cover these costs. The number of households adapting varies between different districts (15 %–21 %), with salt adaptation being the most common, as costs are lowest. Despite adaptation measures, about 13 %–20 % of the total 350 000 farmers in coastal flood zones will migrate to safer areas under different settings of adaptive behaviour and different climatic and socio-economic scenarios.