Social context often has profound effects on behavior, yet the neural and molecular mechanisms which mediate ﬂexible behavioral responses to different social environments are not well understood. We used the African cichlid ﬁsh, Astatotilapia burtoni, to examine aggressive defense behavior across three social contexts representing different motivational states: a reproductive opportunity, a familiar male and a neutral context.To elucidate how differences in behavior across con-texts may be mediated by neural gene expression, we examined gene expression in the preoptic area, a brain region known to control male aggressive and sexual behavior. We show that social context has broad effects on preoptic gene expression. Speciﬁcally, we found that the expression of genes encoding nonapeptides and sex steroid receptors are upregulated in the familiar male context. Furthermore, circulating levels of testosterone and cortisol varied markedly depending on social context. We also manipulated the D2 receptor (D2R) ineach social context, given that it has been implicated in mediating context-dependent behavior. We found that a D2R agonist reduced intruder-directed aggression in the reproductive opportunity and familiar male contexts, while a D2R antagonist inhibited intruder-directed aggression in the reproductive opportunity context and increased aggression in the neutral context. Our results demonstrate a critical role for preoptic gene expression, as well as circulating steroid hormone levels, in encoding information from the social environment and in shaping adaptive behavior. In addition, they provide further evidence for a role of D2R in context-dependent behavior.