Microorganisms encounter a diversity of chemical stimuli that trigger individual responses and influence population dynamics. However, microbial behavior under the influence of different incentives and microbial decision-making is poorly understood. Benthic marine diatoms that react to sexual attractants as well as to nutrient gradients face such multiple constraints. Here, we document and model behavioral complexity and context-sensitive responses of these motile unicellular algae to sex pheromones and the nutrient silicate. Throughout the life cycle of the model diatom Seminavis robusta nutrient-starved cells localize sources of silicate by combined chemokinetic and chemotactic motility. However, with an increasing need for sex to restore the initial cell size, a change in behavior favoring the attraction-pheromone-guided search for a mating partner takes place. When sex becomes inevitable to prevent cell death, safeguard mechanisms are abandoned, and cells prioritize the search for mating partners. Such selection processes help to explain biofilm organization and to understand species interactions in complex communities.