The relatively rapid spread and diversity of marine pathogens posed an initial and ongoing challenge for cetaceans (whales, dolphins, and porpoises), descendants of terrestrial mammals that transitioned from land to sea approximately 56 million years ago. Toll-like receptors (TLRs) play important roles in regulating immunity against pathogen infections by detecting specific molecular patterns and activating a wide range of downstream signaling pathways. The ever-increasing catalogue of mammalian genomes offers unprecedented opportunities to reveal genetic changes associated with evolutionary and ecological processes. This study aimed to explore the molecular evolution of TLR signaling pathway genes in cetaceans. Genes involved in the TLR signaling pathway were retrieved by BLAST searches using human coding sequences as queries. We tested each gene for positive selection along the cetacean branches using PAML and Hyphy. Physicochemical property changes of amino acids at all positively selected residues were assessed by TreeSAAP and visualized with WebLogo. Bovine and dolphin TLR4 was assessed using human embryonic kidney cell line HEK293, which lacks TLR4 and its co-receptor MD-2. We demonstrate that eight TLR signaling pathway genes are under positive selection in cetaceans. These include key genes in the response to Gram-negative bacteria: TLR4, CD14, and LY96 (MD-2). Moreover, 41 out of 65 positively selected sites were inferred to harbor substitution that dramatically changes the physicochemical properties of amino acids, with most of them situated in or adjacent to functional regions. We also found strong evidence that positive selection occurred in the lineage of the Yangtze finless porpoise, likely reflecting relatively recent adaptions to a freshwater milieu. Species-specific differences in TLR4 response were observed between cetacean and terrestrial species. Cetacean TLR4 was significantly less responsive to lipopolysaccharides from a terrestrial E. coli strain, possibly a reflection of the arms race of host-pathogen co-evolution faced by cetaceans in an aquatic environment. This study provides further impetus for studies on the evolution and function of the cetacean immune system.