In aquatic habitats prey often show maximum responsiveness to predators when they are exposed to kairomones and alarm cues in combination. As alarm cues can derive from heterospecific as well as conspecific animals, prey may need to fine tune their responses depending on the taxa with which they co-occur. We used juveniles of the freshwater gastropod, Lymnaea stagnalis L. (great pond snail) to test whether the response to heterospecific alarm cues could be enhanced by cohabitation in the absence of predators, and therefore without the potential for cue association learning. Snails were raised from oviposition alongside one of four other pulmonate species, differing in their phylogenetic relatedness to L. stagnalis, that is, from intragenus to intrasuborder. The antipredator response to heterospecific alarm cues paired with fish kairomones was then compared with the response of L. stagnalis reared in isolation. Cohabitation increased the response to heterospecific alarm cues paired with fish kairomones only when L. stagnalis had developed in the presence of closely related (Lymnaea fusca and Radix balthica) rather than distantly related heterospecifics (Physella acuta and Planorbarius corneus). Hence, in L. stagnalis, learning to recognize heterospecific alarm cues can occur without the need for cue association but the learnt response is constrained by species' relatedness. This result suggests that differential responses observed in studies based on wild-caught animals in response to heterospecific alarm cues may be explained by learning through cohabitation alone.