In this paper, we investigate the nexus between urban air pollution and residents’ preferences for greenspace. We first provide a theoretical discussion on three potential mechanisms that link these two environmental issues. To start with, where people choose to locate in a city, as reflected by their exposure to air pollution, may indicate their preferences for greenspace through a residential sorting effect: residents of heavily polluted neighbourhoods may have a lower appreciation of environmental amenities in general, including greenspace. Further, air pollution may have direct implications for the use value of greenspace. On the one hand, people tend to reduce outdoor activities in severe pollution as an avoidance behaviour, which may lead to reduced visits to and hence lower use value of greenspace. On the other hand, residents of severely polluted areas may derive additional benefits from greenspace, as trees are able to enhance air quality. To empirically test these mechanisms, we undertook choice experiment surveys in Beijing to elicit the public’s willingness to pay (WTP) for greenspace. We purposefully valued three types of greenspace: a neighbourhood park near respondents' homes; a city park in central Beijing; and a national park in an outlying location. We use realtime pollution data to help explain the spatial and temporal variation in WTP, whilst controlling for other possible influencing factors. Neighbourhood parks are likely to provide direct air purification services for communities nearby, and our results indeed suggest that respondents exposed to higher levels of annual pollution are willing to pay more for an additional neighbourhood park. In contrast, WTP for the city park and national park is more likely to be linked with pollution levels via the residential sorting and reduced visits mechanisms. Yet our results find no evidence for such connections.