Sleep is broken up into two stages: rapid eye movement (REM) and non-rapid eye movement (non-REM.)
REM and non-REM sleep alternates in 90-100 minute cycles.
Most dreaming occurs during REM sleep. Nightmares usually occur in the middle of the night or in early morning, where REM sleep and dreaming are more common.