How do we know our social rank? Most social species, from insects to humans, self-organize into social dominance hierarchies (1–4). The establishment of social ranks serves to decrease aggression, conserve energy, and maximize survival for the entire group (5–8). Despite dominance behaviors being critical for successful interactions and ultimately, survival, we have only begun to learn how the brain represents social rank (9–12) and guides behavior based on this representation. The medial prefrontal cortex (mPFC) has been implicated in the expression of social dominance in rodents (10,11), and in social rank learning in humans (13,14). Yet precisely how the mPFC encodes rank and which circuits mediate this computation is not known. We developed a trial-based social competition assay in which mice compete for rewards, as well as a computer vision tool to track multiple, unmarked animals. With the development of a deep learning computer vision tool (AlphaTracker) and wireless electrophysiology recording devices, we have established a novel platform to facilitate quantitative examination of how the brain gives rise to social behaviors. We describe nine behavioral states during social competition that were accurately decoded from mPFC ensemble activity using a hidden Markov model combined with generalized linear models (HMM-GLM). Population dynamics in the mPFC were predictive of social rank and competitive success. This population-level rank representation translated into differences in the individual cell responses to task-relevant events across ranks. Finally, we demonstrate that mPFC cells that project to the lateral hypothalamus contribute to the prediction of social rank and promote dominance behavior during the reward competition. Thus, we reveal a cortico-hypothalamic circuit by which mPFC exerts top-down modulation of social dominance.