How does high-intensity aerobic exercise affect the brain?
In this article The Effects of Acute Exercise on Mood, Cognition, Neurophysiology, and Neurochemical Pathways: A Review (Brain Plasticity, 2017), there's a comprehensive table The Time Course of Behavioral, Functional, Physiological, and Neurochemical Effects of Acute Exercise (scroll to Fig 1 and zoom it) that shows the duration and intensity of exercise needed for the effective release of cortisol, neurotrophins (BDNF, IGF-1), neurotransmitters (dopamine, norepinephrine, serotonin, acetylcholine, GABA and gltamate) and endogenous opioids.

Examples of effects of exercise on the cognitive function and mood:


Prefrontal-dependent cognitive function (learning, memory): 50 min exercise at 85% of age-predicted mean heart rate
Enhancement of positive mood: low to high intensity exercise 7-70 min
Decrease in negative mood: 60-120 min exercise at ~50% intensity


Cortisol:


  In humans, acute exercise stimulates the HPA axis in an
  intensity-dependent fashion, with increases in cortisol occurring
  after a threshold amount of exercise that equates to a duration of 10
  minutes or more at approximately 60% of VO2 max or greater...After
  exercise cessation, peripheral cortisol levels peak around 30 minutes
  and remain elevated for up to two hours.
  
  ...cortisol strongly influences learning and memory...The extent
  to which cortisol influences learning and memory processes depends on
  several factors including the intensity of cortisol elevation. For
  example, moderate increases in cortisol enhance working memory...Cortisol elevation over a certain threshold, however, serves to impair memory...
  
  acute exercise also helps mitigate the debilitating effects of stress.


Brain derived neurotrophic factor (BDNF):

Moderate exercise for 30 minutes can release BDNF.


  ...studies have shown a positive association between acute
  exercise-induced peripheral BDNF levels and short-term memory as
  well as motor skill memory.


But, this does not work in everyone and not in all circumstances...

Dopamine:


  Twelve, healthy, regular exercisers underwent PET scans after either
  rest or 30 minutes of treadmill running at 85% of age-predicted MHR.
  Surprisingly, dopamine was not found to increase after acute exercise
  in these humans.


Serotonin:


  Acute exercise significantly increased plasma serotonin, with a
  positive linear correlation found between serotonin concentration and
  exercise intensity.
  
  As serotonin regulates mood, emotion, sleep, and appetite, and
  dopamine regulates motivation memory, reward, and attention, the
  central fatigue hypothesis claims that the interaction between these
  two neurotransmitters contributes to exercise-induced fatigue, with a
  high serotonin to dopamine ratio supporting a low activity, exhausted state and a low ratio supporting a high activity, activated
  state.


The effects of exercise-induced increase of norepinephrine and acetylcholine on cognitive function are not well known.

Endogenous opioids (ß-endorphins, enkephalins and dynorphins) and endocannabinoids:


  Neuromodulators are involved in a variety of processes including pain
  modulation, reward, response to stress, and autonomic control. 
  
  In humans, acute exercise causes significant increases in peripheral
  levels of endogenous opioids; this effect is intensity-dependent,
  corresponds to acute exercise-induced changes in HPA axis hormones,
  and is linked to improvements in mood.
  
  Though the endogenous opioids have received much attention in terms of
  their involvement in the “runner’s high”, scientists are beginning to
  understand that endocannabinoids may be equally or perhaps more
  involved.




Other sources:

Effects of physical exercise on anxiety, depression...(Clinical Psychology Review, 2001):


  Acutely, emotional effects of exercise remain confusing, both positive
  and negative effects being reported.


...or as Alex Corb, PhD says in Boosting Your Serotonin Activity (Psychology Today):


  Interestingly, if you try to do too much exercise, or feel forced into
  doing it, it may not have the right effect. Recognizing that you are
  choosing to exercise changes its neurochemical effect. That may be a
  result of your ancient instincts — the difference between running
  because you're hunting something, and running because it's hunting
  you.


How to increase serotonin in the human brain without drugs (Journal of Psychiatry &amp; Neuroscience, 2007):


  Exercise improves mood in subclinical populations as well as in
  patients. The most consistent effect is seen when regular exercisers
  undertake aerobic exercise at a level with which they are familiar.