The lactose operon (lac operon) is an operon required for the transport and metabolism of lactose in E. coli and many other enteric bacteria. Although glucose is the preferred carbon source for most enteric bacteria, the lac operon allows for the effective digestion of lactose when glucose is not available through the activity of beta-galactosidase. Gene regulation of the lac operon was the first genetic regulatory mechanism to be understood clearly, so it has become a foremost example of prokaryotic gene regulation. It is often discussed in introductory molecular and cellular biology classes for this reason. This lactose metabolism system was used by François Jacob and Jacques Monod to determine how a biological cell knows which enzyme to synthesize. Their work on the lac operon won them the Nobel Prize in Physiology in 1965.
Most bacterial cells including E. coli  lack introns in their genome. They also lack a nuclear membrane. Hence the gene regulation by lac operon occurs at the transcriptional level, by preventing conversion of DNA into mRNA. 
Bacterial operons are polycistronic transcripts that are able to produce multiple proteins from one mRNA transcript. In this case, when lactose is required as a sugar source for the bacterium, the three genes of the lac operon can be expressed and their subsequent proteins translated: lacZ, lacY, and lacA. The gene product of lacZ is β-galactosidase which cleaves lactose, a disaccharide, into glucose and galactose. lacY encodes β-galactoside permease, a membrane protein which becomes embedded in the Plasma membrane to enable the cellular transport of lactose into the cell. Finally, lacA encodes  β-galactoside transacetylase. 
Note that the number of base pairs in diagram given above are not for scale. 
It would be wasteful to produce enzymes when no lactose is available or if a preferable energy source such as glucose were available. The lac operon uses a two-part control mechanism to ensure that the cell expends energy producing the enzymes encoded by the lac operon only when necessary. 
In the absence of lactose, the lac repressor, encoded by lacI, halts production of the enzymes and transport proteins encoded by the lac operon. It does so by blocking the DNA dependent RNA polymerase. This blocking/ halting is not perfect, and a minimal amount of gene expression does take place all the time. The repressor protein is always expressed, but the lac operon (enzymes and transport proteins) are repressed. (But not completely stopped)
When lactose is available but not glucose, then some lactose enters the cell using pre-existing transport protein encoded by lacY. This lactose then combines with the repressor and inactivates it, hence allowing the lac operon to be expressed. Then more β-galactoside permease is synthesized allowing even more lactose to enter and the enzymes encoded by lacZ and lacA can digest it. 
However, In the presence of glucose, regardless of the presence of lactose, the operon will be repressed. This is because the catabolite activator protein (CAP), required for production of the enzymes, remains inactive, and EIIA shuts down lactose permease to prevent transport of lactose into the cell.  This dual control mechanism causes the sequential utilization of glucose and lactose in two distinct growth phases, known as diauxie.