Larval modes of development affect evolutionary processes and influence the distribution of marine invertebrates in the ocean. The decrease in pelagic development toward higher latitudes is one of the patterns of distribution most frequently discussed in marine organisms (Thorson's rule), which has been related to increased larval mortality associated with long pelagic durations in colder waters. However, the type of substrate occupied by adults has been suggested to influence the generality of the latitudinal patterns in larval development. To help understand how the environment affects the evolution of larval types we evaluated the association between larval development and habitat using gastropods of the Muricidae family as a model group. To achieve this goal, we collected information on latitudinal distribution, sea water temperature, larval development and type of substrate occupied by adults. We constructed a molecular phylogeny for 45 species of muricids to estimate the ancestral character states and to assess the relationship between traits using comparative methods in a Bayesian framework. Our results showed high probability for a common ancestor of the muricids with nonpelagic (and nonfeeding) development, that lived in hard bottoms and cold temperatures. From this ancestor, a pelagic feeding larva evolved three times, and some species shifted to warmer temperatures or sand bottoms. The evolution of larval development was not independent of habitat; the most probable evolutionary route reconstructed in the analysis of correlated evolution showed that type of larval development may change in soft bottoms but in hard bottoms this change is highly unlikely. Lower sea water temperatures were associated with nonpelagic modes of development, supporting Thorson's rule. We show how environmental pressures can favor a particular mode of larval development or transitions between larval modes and discuss the reacquisition of feeding larva in muricids gastropods.