Blood–brain barrier

The blood–brain barrier (BBB) is a highly selective permeability barrier. It controls what gets from the bloodstream into the brain, and what does not.
For example, things that the brain needs to survive (water, glucose, and amino acids) can get through the barrier. However, the barrier stops many harmful things, like bacteria and viruses, from getting into the brain. This helps protect the brain from getting an infection.
The blood-brain barrier is formed by capillary endothelial cells. It allows the passage of water, some gases, and lipid-soluble molecules by passive diffusion. It also allows the selective transport of molecules such as glucose and amino acids which are crucial to nerve function. On the other hand, the blood-brain barrier may prevent the entry of neurotoxins by means of an active transport mechanism. 
A few small areas in the brain do not have a blood-brain barrier. 
Discovery.
Paul Ehrlich, a German doctor, discovered the blood-brain barrier. He injected dye into mice's bloodstreams. The dye got to every organ except the brain. The blood-brain barrier had stopped the dye from getting through to the brain. Then one of Ehrlich's students injected the dye right into the mice's brains. This time the brain turned blue, but no other organs did. The blood-brain barrier had stopped the dye from getting out of the brain into the bloodstream (which would have carried the dye to every other organ in the body).
Function.
The blood–brain barrier protects the brain from many common infections. Infections of the brain are rare. If they do happen, they are often serious and difficult to treat. Antibodies (which the body's immune system makes to fight infections) are too large to cross the blood–brain barrier. Also, many antibiotics cannot pass through the BBB to kill the infection in the brain. 
One way to get medications into the brain is to inject them into the cerebrospinal fluid (CSF). CSF helps protect the brain and spinal cord. However, it does not actually touch the brain. Instead, two of the layers that protect the brain and spinal cord hold the CSF. Because of this, even if medications are injected right into the CSF, they still do not get into the brain very well. 
Some bacteria, viruses, and other things can get through the blood-brain barrier and damage the brain. For example: