California ground squirrels (Otospermophilus beecheyi) harass rattlesnakes (Crotalus oreganus) using a tail-flagging display that seemingly deters predation. Previous studies suggest that tail flagging could communicate vigilance in addition to perception of a snake. I tested the function and ontogeny of tail flagging through experiments on both free-ranging squirrels and snakes. I first used an array of network security cameras to record natural rattlesnake foraging behavior and squirrel-snake interactions. This confirmed that squirrels are the primary food item of rattlesnakes in the study population, accounting for more than 90% of all prey encounters and prey consumed. I then tested whether tail flagging signals vigilance in the absence of snakes using an experiment that simulated snake strikes on free-ranging squirrels either 1) in the presence of a rattlesnake, 2) with no snake present, or 3) in an area where squirrels had recently encountered a snake that was no longer present (vigilance treatment). Squirrels tail flagged most when interacting with a snake, but they also signaled in areas of recent snake encounters during which they responded fastest to simulated strikes and were most likely to leap away from the attack. Hence, tail flagging honestly signals vigilance even when snakes are undetected. The third part of my research examined age differences in antisnake behaviors during the detection, interaction, and attack stages of a rattlesnake encounter. Compared to adults, pups were worse at detecting snakes, performed fewer tail-flagging bouts, were less likely to investigate a hidden snake's refuge, and reacted slower to simulated strikes. I concluded that pups avoid rattlesnakes and minimize time spent in close proximity to them to compensate for their reduced reactiontimes to strikes. Finally, I determined which situational context surrounding snake encounters influenced variation in snake-harassment behavior and physiological stress responses, characterized by fecal assays of corticosterone. In the absence of conspecifics, squirrels exhibited higher stress responses to snakes that persisted in their environment, and the amount of time squirrels spent harassing snakes was influenced by complex interactions between conspecific presence, snake species, and the length of time snakes stayed in the area. I also found consistent individual differences in stress responses and snake-harassment behavior, suggesting that these traits could be important targets of natural selection. Overall, my work found that tail flagging is a complex antisnake signal that can serve different functions and is influenced by both intrinsic and extrinsic factors.