Little research has examined the correlates of children's social withdrawal in real-world contexts beyond the classroom. Here, we used a surgical setting as an ecologically salient stress model to study one type of social withdrawal: shyness. Participants were 171 children (Mage = 10.1 years, SDage = 1.7, range = 7-13 years, 50.1% boys), who were undergoing elective surgery, and their parents (Mage = 40.7 years, SDage = 6.8, range = 29-59 years, 76.2% mothers). Children's self-report of temperamental shyness and preoperative state anxiety as well as parents' report of trait anxiety were assessed 7 to 10 days before surgery (T1). On the morning of surgery (T2), children and parents self-reported on state anxiety. In the operating room (T3), children's behaviors were video-recorded and coded for observed distress. We found children's preoperative state anxiety (T1 and T2) fully mediated the relation between shyness and observed distress, regardless of participant age, sex, and parent trait and state anxiety. This mediated relation was qualified by child age. In ages 7 to 9, preoperative anxiety was predictive of observed distress. By comparison, in ages 10 to 13, shyness was related to higher levels of preoperative anxiety, controlling for participant sex, and parent trait and state anxiety. These findings illustrate the effects of child temperament and developmental age on behavior, beyond parental influences, in a real-world context.