Aflatoxin M1 (AFM1) is detected in the milk of animals after ingestion of aflatoxin B1-contaminated food; since 2002, it has been categorized as a group I carcinogen. In this work, a silicon-based optoelectronic immunosensor for the detection of AFM1 in milk, chocolate milk, and yogurt has been developed. The immunosensor consists of ten Mach–Zehnder silicon nitride waveguide interferometers (MZIs) integrated on the same chip with the respective light sources, and an external spectrophotometer for transmission spectra collection. The sensing arm windows of MZIs are bio-functionalized after chip activation with aminosilane by spotting an AFM1 conjugate with bovine serum albumin. For AFM1 detection, a three-step competitive immunoassay is employed, including the primary reaction with a rabbit polyclonal anti-AFM1 antibody, followed by biotinylated donkey polyclonal anti-rabbit IgG antibody and streptavidin. The assay duration was 15 min with limits of detection of 0.005 ng/mL in both full-fat and chocolate milk, and 0.01 ng/mL in yogurt, which are lower than the maximum allowable concentration of 0.05 ng/mL set by the European Union. The assay is accurate (% recovery values 86.7–115) and repeatable (inter- and intra-assay variation coefficients <8%). The excellent analytical performance of the proposed immunosensor paves the way for accurate on-site AFM1 determination in milk.