The Immune System: How It Works Explained

Photo: Maksim Goncharenok / Pexels
Your body is under constant attack. Every breath you take, every surface you touch, every meal you eat introduces potential pathogens — bacteria, viruses, fungi, and parasites — that would happily colonize your tissues. The fact that you are alive and reading this sentence is a testament to one of evolution's most sophisticated engineering projects: the human immune system.
The immune system is not a single organ but a distributed, multi-layered defense network spanning every tissue in your body. It operates across three overlapping lines of defense, deploys dozens of specialized cell types, and communicates through an elaborate molecular language of cytokines and surface receptors. Understanding how it works illuminates everything from why vaccines protect us to why autoimmune diseases develop and how modern cancer therapies exploit immune machinery.
Three Lines of Defense
The immune response is traditionally divided into three integrated layers:
- Physical and chemical barriers — the first wall preventing pathogens from entering
- Innate immunity — fast, non-specific responses that act within minutes to hours
- Adaptive immunity — slow, highly specific responses that take days to weeks but generate lasting memory
Each layer feeds information to the next, and together they form an interconnected system capable of recognizing and neutralizing an almost unlimited variety of threats.
Line 1: Physical and Chemical Barriers
Before any immune cell fires a single shot, the body's surfaces block the vast majority of potential invaders.
Skin is the most obvious barrier. The outer layer (stratum corneum) consists of dead, keratin-filled cells stacked in overlapping sheets — a near-impenetrable mechanical wall. Beyond mechanics, skin is slightly acidic (pH 4.5–5.5), which inhibits bacterial growth. Sebaceous glands secrete fatty acids and antimicrobial peptides (defensins) that kill many pathogens on contact.
Mucous membranes line every internal surface open to the outside world — respiratory tract, gastrointestinal tract, urogenital tract. Mucus physically traps particles; cilia in the airways sweep trapped material upward (the mucociliary escalator); stomach acid (pH ~2) destroys most ingested organisms; and the gut is colonized by ~38 trillion commensal bacteria that out-compete pathogens for nutrients and attachment sites.
Secretions add another chemical layer: tears and saliva contain lysozyme, an enzyme that cleaves bacterial cell walls; the respiratory mucus contains IgA antibodies; and breast milk transfers maternal immunoglobulins to newborns whose own adaptive immunity is not yet mature.
When pathogens breach these barriers — through a cut, an inhaled droplet, or a contaminated meal — the second line engages immediately.
Line 2: Innate Immunity — Fast and Non-Specific
The innate immune system evolved first and is shared across virtually all multicellular life. It does not need prior exposure to a pathogen; instead it recognizes conserved molecular patterns common to broad classes of microorganisms.
Pattern Recognition Receptors and PAMPs
Innate immune cells carry pattern recognition receptors (PRRs), the most studied of which are Toll-like receptors (TLRs). Humans have 10 functional TLRs, each tuned to detect specific pathogen-associated molecular patterns (PAMPs) — molecular signatures absent from healthy host cells.
For example:
- TLR4 detects lipopolysaccharide (LPS) on gram-negative bacterial outer membranes
- TLR3 detects double-stranded RNA (a sign of viral replication)
- TLR9 detects unmethylated CpG DNA motifs common in bacteria and viruses
Binding a PAMP triggers downstream signaling (via NF-κB and IRF pathways) that rapidly switches on genes for inflammation, antiviral proteins (interferons), and recruitment signals.
Key Innate Immune Cells
Neutrophils are the shock troops — the most abundant white blood cells and the first to arrive at sites of infection. They engulf and destroy bacteria through phagocytosis, and they also release neutrophil extracellular traps (NETs), meshes of DNA and antimicrobial proteins that ensnare bacteria. Their lifespan is only hours to days.
Macrophages are versatile phagocytes that reside in virtually every tissue (liver Kupffer cells, brain microglia, lung alveolar macrophages). They engulf debris and pathogens, release pro-inflammatory cytokines (TNF-α, IL-1β, IL-6), and present pathogen fragments on their surface — a function critical for activating the adaptive immune system.
Dendritic cells are arguably the most important bridge between innate and adaptive immunity. After engulfing pathogens, they migrate to the nearest lymph node, mature, and present pathogen-derived peptide fragments to naïve T cells, initiating adaptive responses.
Natural killer (NK) cells patrol the body looking for cells that have "gone dark" — virus-infected or cancerous cells that downregulate MHC class I molecules to hide from cytotoxic T cells. NK cells kill these targets through perforin-mediated pore formation and granzyme injection without requiring antibodies or prior sensitization.
The Complement System
The complement system is a cascade of ~30 serum proteins that, once activated, tag pathogens for destruction (opsonization), punch holes in bacterial membranes (membrane attack complex), and recruit phagocytes through chemotaxis. Three activation pathways (classical, lectin, alternative) converge on a common amplification cascade. Complement proteins deposited on a bacterial surface act as "eat me" signals for neutrophils and macrophages.
Inflammation: Beneficial and Harmful
Inflammation is the hallmark innate response. When tissue is damaged or infected, local macrophages release cytokines (TNF-α, IL-1, IL-6) and chemokines that dilate blood vessels, increase vascular permeability (causing redness, heat, and swelling), and recruit circulating neutrophils. This controlled inflammation contains local infection and begins tissue repair.
However, when inflammation is systemic and uncontrolled — as in sepsis — the cytokine storm can damage host tissues, cause multi-organ failure, and be fatal. Chronic low-grade inflammation underlies atherosclerosis, type 2 diabetes, and many neurodegenerative diseases, making its precise regulation a major therapeutic target.
Line 3: Adaptive Immunity — Slow, Specific, and Remembered
If innate immunity is the standing army, adaptive immunity is the bespoke special forces — individually trained against a single enemy. It takes 5–14 days to mount a first response, but it generates immunological memory that makes subsequent encounters faster and stronger.
Innate vs. Adaptive Immunity: A Comparison
| Feature | Innate Immunity | Adaptive Immunity |
|---|---|---|
| Response time | Minutes to hours | Days to weeks |
| Specificity | Broad (PAMPs) | Exquisitely specific (single epitope) |
| Memory | None | Yes — decades-long |
| Key cells | Neutrophils, macrophages, NK cells, dendritic cells | T lymphocytes, B lymphocytes |
| Receptors | Germline-encoded (TLRs, NLRs) | Somatically rearranged (BCR, TCR) |
| Diversity | Limited (~10 receptor types) | >10¹⁵ possible specificities |
| Evolution | Ancient (shared with invertebrates) | Jawed vertebrates only (~500 Mya) |
| Role in vaccines | Adjuvant-driven activation | Generates memory cells |
B Cells and Antibodies
B cells are the antibody factories of the immune system. Each B cell expresses a unique B cell receptor (BCR) — a membrane-bound antibody generated by random recombination of V, D, and J gene segments, producing a theoretical diversity exceeding 10¹¹ specificities.
When a B cell encounters its matching antigen, it requires additional help to become fully activated. Typically, an activated CD4+ helper T cell specific to a peptide from the same pathogen recognizes the antigen on the B cell's surface and delivers costimulatory signals (CD40L–CD40 interaction) plus cytokines (IL-4, IL-21). This "linked recognition" ensures antibodies are not made accidentally against self-antigens.
Activated B cells enter germinal centers in lymph nodes, where they undergo somatic hypermutation — deliberately introducing point mutations into their BCR genes at a rate ~10⁶ times the genomic background. B cells with mutations that improve antigen binding outcompete those with weaker binding in a process called affinity maturation. Over weeks, this Darwinian competition produces antibodies with affinities measured in the picomolar range — billions of times tighter than the initial response.
Antibody classes produced:
- IgM — first antibody class secreted; a pentamer effective at complement activation
- IgG — dominant in secondary responses; crosses the placenta to protect newborns
- IgA — secreted into mucus, saliva, and breast milk
- IgE — mediates allergy and antiparasite responses
- IgD — primarily a B cell surface receptor; function still debated
Memory B cells persist for decades after infection, enabling rapid, high-affinity antibody production upon re-exposure — the immunological basis of vaccination.
T Cells: Orchestrators and Executioners
T cells develop in the thymus, where each acquires a unique T cell receptor (TCR) through V(D)J recombination. Unlike BCRs, TCRs cannot recognize free antigen — they only see short peptide fragments (8–15 amino acids) presented in the groove of MHC molecules on the surface of other cells.
MHC class I molecules are expressed on virtually every nucleated cell in the body. They display peptides from proteins made inside the cell — including viral proteins during infection. CD8+ cytotoxic T cells (CTLs) inspect class I molecules; if they detect a foreign peptide, they kill the presenting cell using:
- Perforin — punches pores in the target cell membrane
- Granzymes — serine proteases delivered through perforin pores that trigger apoptosis
- Fas ligand — binds Fas receptor on target cell, triggering programmed death
MHC class II molecules are expressed only on professional antigen-presenting cells (dendritic cells, macrophages, B cells). They display peptides from proteins engulfed from outside the cell. CD4+ helper T cells read class II molecules and, upon activation, differentiate into functional subsets:
- Th1 — drive cellular immunity; activate macrophages to destroy intracellular bacteria (e.g., Mycobacterium tuberculosis); secrete IFN-γ
- Th2 — drive humoral and anti-parasite immunity; promote IgE production; secrete IL-4, IL-5, IL-13
- Th17 — defend mucosal surfaces against fungi and extracellular bacteria; secrete IL-17
- Tregs (regulatory T cells) — suppress immune activation to prevent autoimmunity; express FoxP3 transcription factor
Thymic education is the process that ensures T cells are useful but not self-destructive. In the thymus, developing T cells undergo:
- Positive selection: T cells that can interact with self-MHC survive; those that cannot die (98% are eliminated)
- Negative selection: T cells with too-high affinity for self-peptides are deleted to prevent autoimmunity
This dual filter produces a T cell repertoire that is MHC-restricted and self-tolerant — in theory.
Immunological Memory: Why Vaccines Work
After an infection or vaccination, some activated B and T cells differentiate into memory cells rather than effector cells. Memory cells:
- Are long-lived (can persist for 50+ years, possibly a lifetime)
- Are more easily reactivated than naïve cells (lower threshold for stimulation)
- Respond faster (1–3 days vs. 5–14 days)
- Generate larger numbers of effector cells
On re-exposure, memory B cells rapidly produce high-affinity IgG, and memory CTLs quickly kill infected cells before the pathogen can spread. This is why a second infection with the same pathogen is usually milder or asymptomatic — and why vaccines can mimic infection to confer protection without disease.
Modern mRNA vaccines (such as COVID-19 vaccines) deliver instructions for cells to produce a pathogen protein transiently, triggering both innate sensing and adaptive memory without any risk of infection.
When the System Breaks Down
Autoimmune Diseases
If central (thymic) or peripheral tolerance fails, autoreactive T cells or B cells escape and attack self-tissues. Autoimmune diseases affect roughly 5–8% of the population.
Proposed mechanisms include:
- Molecular mimicry — pathogen peptides resemble self-peptides, confusing immune cells (e.g., Streptococcus triggering rheumatic fever via cardiac cross-reactivity)
- Bystander activation — inflammation non-specifically activates quiescent autoreactive cells
- Regulatory T cell failure — loss of FoxP3+ Tregs removes the brake
Common autoimmune conditions:
- Multiple sclerosis (MS) — Th1/Th17 cells attack myelin sheaths in the CNS
- Rheumatoid arthritis — synovial joints destroyed by autoreactive T cells and TNF-α
- Type 1 diabetes — CTLs destroy insulin-producing β cells in pancreatic islets
- Systemic lupus erythematosus (SLE) — anti-dsDNA and anti-Smith antibodies form immune complexes deposited in kidneys, joints, and skin
Allergies and IgE
Allergies arise when the Th2 arm of adaptive immunity mounts a response against harmless environmental antigens (allergens). The sequence:
- Initial sensitization: allergen exposure → Th2 polarization → IgE production
- IgE binds to high-affinity receptors (FcεRI) on mast cells and basophils
- Re-exposure: allergen cross-links IgE on mast cells → degranulation → release of histamine, leukotrienes, prostaglandins
- Symptoms: vasodilation, bronchoconstriction, mucus secretion (hay fever, asthma, anaphylaxis)
Immunodeficiency
Primary immunodeficiencies are genetic. Severe combined immunodeficiency (SCID) — the "bubble boy" disease — eliminates both T and B cell development through mutations in genes such as IL2RG (common gamma chain) or ADA (adenosine deaminase). Without treatment, infants succumb to infections within months.
Selective IgA deficiency is the most common primary immunodeficiency (~1 in 500 people), often asymptomatic but associated with recurrent respiratory infections and a higher rate of autoimmunity.
HIV/AIDS is the paradigmatic acquired immunodeficiency. HIV preferentially infects and destroys CD4+ helper T cells (using CD4 and CCR5/CXCR4 co-receptors). As CD4 counts fall below 200 cells/μL, the coordinated architecture of adaptive immunity collapses, leaving patients susceptible to opportunistic infections (Pneumocystis pneumonia, CMV retinitis, cerebral toxoplasmosis) that a healthy immune system would easily control.
Immunotherapy: Turning the Immune System Against Cancer
Cancer cells accumulate mutations that can generate neoantigens — foreign-looking peptides displayed on MHC class I — which CTLs can theoretically recognize and kill. The problem is that tumors evolve mechanisms to evade immune detection, chief among them upregulating checkpoint molecules that send "stop" signals to T cells.
- PD-1 (on T cells) binding PD-L1 (on tumor cells) exhausts T cell activity
- CTLA-4 competes with CD28 on T cells, dampening activation signals
Checkpoint inhibitors — monoclonal antibodies that block PD-1 (pembrolizumab, nivolumab) or CTLA-4 (ipilimumab) — remove these brakes, allowing exhausted tumor-infiltrating T cells to re-activate and kill cancer cells. In certain cancers (melanoma, non-small cell lung cancer, renal cell carcinoma), checkpoint inhibitors produce durable remissions in patients who previously had no effective options.
The same mechanism that makes checkpoint inhibitors effective also explains their side effects — immune-related adverse events (irAEs) including colitis, pneumonitis, and endocrinopathies — because releasing immune brakes can tip toward autoimmunity.
Frequently Asked Questions
Q: What is the difference between innate and adaptive immunity? A: Innate immunity is fast (minutes to hours), non-specific, and has no memory — it responds the same way to every encounter with a pathogen. Adaptive immunity is slow (days to weeks), exquisitely specific to a single antigen, and generates immunological memory that makes future responses faster and stronger.
Q: How do vaccines create immunity without causing disease? A: Vaccines introduce a harmless version of a pathogen (killed organism, subunit protein, mRNA) that triggers innate sensing and drives adaptive responses — T cell activation and antibody production — without the pathogen's ability to replicate and cause illness. Memory cells generated persist for years, enabling rapid protection upon real exposure.
Q: Why does the immune system not attack our own cells? A: Two main checkpoints enforce self-tolerance. In the thymus, T cells with receptors that bind too strongly to self-peptides are deleted (negative selection). In peripheral tissues, regulatory T cells (Tregs) continuously suppress autoreactive cells that escaped thymic deletion. Failure of these checkpoints underlies autoimmune diseases.
Q: What are CD4 and CD8 T cells and why does HIV target CD4? A: CD4+ helper T cells coordinate the entire adaptive immune response — they activate B cells, enhance CTL responses, and regulate macrophage activity. CD8+ cytotoxic T cells directly kill infected or cancerous cells. HIV preferentially infects CD4+ T cells because it uses the CD4 protein as a docking receptor, progressively destroying the orchestrators of immunity.
Q: How do NK cells know which cells to kill? A: NK cells use a "missing self" recognition strategy. Healthy cells display MHC class I molecules that engage inhibitory receptors on NK cells, sending a "don't kill me" signal. Virus-infected and cancer cells often downregulate MHC class I to hide from CTLs — but this removes the inhibitory signal, allowing NK cells to kill them without needing antibodies.
Q: What causes allergies and why are they becoming more common? A: Allergies result from Th2-skewed immune responses to harmless environmental antigens, producing IgE antibodies that coat mast cells. Re-exposure causes mast cell degranulation and allergic symptoms. The hygiene hypothesis proposes that reduced childhood microbial exposure in developed countries fails to properly train regulatory immune responses, allowing Th2 reactions to dominate and increasing allergy prevalence.
Q: How do checkpoint inhibitors treat cancer? A: Tumors upregulate checkpoint molecules (PD-L1) that bind inhibitory receptors (PD-1) on T cells, exhausting anti-tumor immunity. Checkpoint inhibitor drugs (pembrolizumab, nivolumab, ipilimumab) are antibodies that block these interactions, releasing the brakes on tumor-infiltrating T cells and allowing them to resume killing cancer cells.
Q: What is somatic hypermutation and why does it matter? A: Somatic hypermutation is a deliberate process in germinal centers where activated B cells introduce random mutations into their antibody genes at rates far above normal. B cells whose mutations improve antigen binding outcompete others and survive — a molecular Darwinian competition called affinity maturation. This process produces antibodies with picomolar affinity, far tighter than the initial response, and is why vaccines with booster doses generate better protection.
Further Reading
For deeper exploration of related topics, see our articles on how viruses work, the biology of vaccines, what cancer is at the cellular level, CRISPR gene editing, and the human microbiome and health.
Sources
- Janeway CA Jr, et al. Immunobiology: The Immune System in Health and Disease. 9th ed. Garland Science, 2017.
- Murphy K, Weaver C. Janeway's Immunobiology. 9th ed. W.W. Norton, 2016.
- Medzhitov R, Janeway CA Jr. "Innate immunity." New England Journal of Medicine 343(5):338–344, 2000. doi:10.1056/NEJM200008033430506
- Victora GD, Nussenzweig MC. "Germinal centers." Annual Review of Immunology 30:429–457, 2012. doi:10.1146/annurev-immunol-020711-075032
- Sharpe AH, Pauken KE. "The diverse functions of the PD1 inhibitory pathway." Nature Reviews Immunology 18(3):153–167, 2018. doi:10.1038/nri.2017.108
- Rosenblum MD, Remedios KA, Abbas AK. "Mechanisms of human autoimmunity." Journal of Clinical Investigation 125(6):2228–2233, 2015. doi:10.1172/JCI78088
- Bjørnsson B, et al. "Digital twins to personalize medicine." Genome Medicine 12(1):4, 2020.
- Parkin J, Cohen B. "An overview of the immune system." The Lancet 357(9270):1777–1789, 2001. doi:10.1016/S0140-6736(00)04904-7
Read next:
Follow new articles
Add SciHub101 to your feed reader to see new science and technology stories.
About the Author
SciHub101 is an independent science and technology publication founded and edited by Buğra Sözeri, a software engineer and app developer based in Türkiye. AI tools assist with drafting and research. Source documentation in the existing archive is uneven, and articles are being reviewed and corrected. The Editorial Team byline identifies editorial responsibility; it does not certify specialist or independent human review. Where we compare products, anything built by our own team is labelled as such — see the editorial guidelines and About page for how corrections and disclosures work.
Related Articles

The Biology of Aging and Longevity Science
How aging works at the cellular level — hallmarks, senescence, NAD+, rapamycin, and the latest longevity interventions explained.

Alzheimer's Disease: The Biology Behind the Decline
How amyloid plaques, tau tangles, and neuronal death drive Alzheimer's—plus new blood tests, FDA-approved drugs, and prevention evidence.

How the Human Immune System Fights Viruses: A Step-by-Step Guide
When a virus enters your body, it triggers a response that unfolds in stages over hours, days, and weeks. The innate immune system fires within minutes, buying time while the adaptive immune system — which can generate targeted weapons against any pathogen — prepares a precise counterattack. The two systems do not operate independently: each depends on signals from the other, and the timing of their interaction determines whether the infection is cleared in a week or becomes severe.

How Vaccines Work — The Biology Behind Immunity
Discover the biology behind vaccines: how antigens, B cells, T cells, and memory cells create lasting protection — and why boosters matter.

How Vaccines Work: The Immune Response Behind Immunization
Vaccines don't just prevent one disease — they teach the immune system a skill it uses for life. Here's the biology.

How the Immune System Works: Innate, Adaptive, and Vaccines
The immune system is not a single organ or a single type of cell — it is a distributed surveillance network that distinguishes your own tissue from foreign invaders within minutes, then builds custom molecular weapons if the first response is not enough. Here is how.