Social context often has profound effects on behav-ior, yet the neural and molecular mechanisms whichmediate ﬂexible behavioral responses to different socialenvironments are not well understood. We used theAfrican cichlid ﬁsh, Astatotilapia burtoni, to examineaggressive defense behavior across three social contextsrepresenting different motivational states: a reproduc-tive opportunity, a familiar male and a neutral context.To elucidate how differences in behavior across con-texts may be mediated by neural gene expression, weexamined gene expression in the preoptic area, a brainregion known to control male aggressive and sexualbehavior. We show that social context has broad effectson preoptic gene expression. Speciﬁcally, we found thatthe expression of genes encoding nonapeptides andsex steroid receptors are upregulated in the familiarmale context. Furthermore, circulating levels of testos-terone and cortisol varied markedly depending on socialcontext. We also manipulated the D2 receptor (D2R) ineach social context, given that it has been implicatedin mediating context-dependent behavior. We foundthat a D2R agonist reduced intruder-directed aggressionin the reproductive opportunity and familiar male con-texts, while a D2R antagonist inhibited intruder-directedaggression in the reproductive opportunity context andincreased aggression in the neutral context. Our resultsdemonstrate a critical role for preoptic gene expression,as well as circulating steroid hormone levels, in encodinginformation from the social environment and in shap-ing adaptive behavior. In addition, they provide furtherevidence for a role of D2R in context-dependent behavior.