Electrophoresis is a process which enables fragments of DNA to be sorted one from another on the basis of the number of base pairs (bp).  In agarose gel electrophoresis, DNA fragments can be sorted from a size of ~100 nucleotides to as large as 50,000 nucleotides.  Since DNA has a negative charge, it tends to migrate from a negative to a positive pole in the electrophoresis chamber when immersed in a liquid buffer.
 

Larger fragments migrate less, since the pore size of the agar matrix restricts their movement more than smaller fragments.  This produces a banding pattern on a gel when the DNA is stained by dyes such as methylene blue or ethidium bromide.