A standard approach to model how selection shapes phenotypic traits is the analysis of capture–recapture data relating trait variation to survival. Divergent selection, however, has never been analyzed by the capture–recapture approach. Most reported examples of differences between urban and nonurban animals reflect behavioral plasticity rather than divergent selection. The aim of this paper was to use a capture–recapture approach to test the hypothesis that divergent selection can also drive local adaptation in urban habitats. We focused on the size of the black breast stripe (i.e., tie width) of the great tit ( Parus major), a sexual ornament used in mate choice. Urban great tits display smaller tie sizes than forest birds. Because tie size is mostly genetically determined, it could potentially respond to selection. We analyzed capture/recapture data of male great tits in Barcelona city ( N = 171) and in a nearby (7 km) forest ( N = 324) from 1992 to 2008 using MARK. When modelling recapture rate, we found it to be strongly influenced by tie width, so that both for urban and forest habitats, birds with smaller ties were more trap-shy and more cautious than their larger tied counterparts. When modelling survival, we found that survival prospects in forest great tits increased the larger their tie width (i.e., directional positive selection), but the reverse was found for urban birds, with individuals displaying smaller ties showing higher survival (i.e., directional negative selection). As melanin-based tie size seems to be related to personality, and both are heritable, results may be explained by cautious personalities being favored in urban environments. More importantly, our results show that divergent selection can be an important mechanism in local adaptation to urban habitats and that capture–recapture is a powerful tool to test it.