The scenario is a fresh exposure: an antigen meets the immune system for the very first time. The pattern of antibody production in such a primary response is well defined and explains the answer.
When naive B lymphocytes first recognise antigen, they begin antibody synthesis before any isotype switching has occurred. The default class they release is IgM. Its pentameric structure, with ten binding arms, makes it a powerful early agglutinator and a strong activator of the classical complement pathway, which is exactly what is needed before a refined response matures.
With time, signals from helper T cells drive class switch recombination, and the response shifts toward IgG, which dominates on re-exposure and provides long-lived, high-affinity protection. IgA guards mucosal surfaces and IgD largely functions as a B cell surface receptor, so neither is the initial circulating response. The earliest antibody on first contact is therefore IgM.
\[\boxed{\text{IgM}}\]