Companion planting works through three distinct biological mechanisms, not magic: plants release defensive chemicals into the soil, they disrupt the sensory signals pests use to find their food, and they build habitat for the predators and microorganisms that keep a garden in balance. When gardeners understand which mechanism a pairing relies on, they can choose combinations that target a specific pest, disease, or soil problem rather than following folklore lists. The carrot-and-onion pairing, for instance, is not tradition for tradition's sake — the onion smell puts off carrot root fly, while the smell of carrots puts off onion fly.
As the UC Master Gardeners of San Mateo and San Francisco Counties put it, growing different plants together creates a polyculture, and "using a scientific approach helps us to understand the why and how of successful planting combinations." That approach is what separates a documented pairing from an inherited one.
Mechanism 1: Chemical Interactions (Allelopathy)
The most concrete mechanism in the companion planting literature is allelopathy: plants releasing chemical compounds that suppress other organisms around them. The best-documented example is the marigold. University of Florida IFAS extension materials describe marigold (Tagetes spp.) as a cover crop that produces a substance called alpha-terthienyl, which can aid in the reduction of root-knot nematodes and other disease-promoting organisms, including fungi, bacteria, insects, and some viruses. African marigold (T. erecta) and French marigold (T. patula) are the most commonly used species.
The chemistry behind this is well characterized. A research team studying the marigold exudate alpha-terthienyl — a blue-fluorescing compound with the formula C12H8S3, first isolated from marigolds in 1947 — reports that it is now believed to be the main compound responsible for marigold's nematicidal activity, alongside insecticidal, fungicidal, antiviral, and cytotoxic effects. The compound induces oxidative stress that penetrates the nematode's hypodermis, and the researchers found that its nematicidal activity occurs even without photoactivation, meaning it can work in the shaded soil of a real field rather than only under laboratory light.
For the home gardener, the practical translation is straightforward: marigolds are not decorative luck. They are a plant whose roots actively exude a compound that suppresses plant-parasitic nematodes, making them a genuine partner for nematode-prone vegetable beds.





