F18-positive enterotoxigenic and Shiga toxin-producing Escherichia coli are responsible for post-weaning diarrhoea and oedema disease in pigs and lead to severe production losses in the farming industry. F18 fimbriae attach to the small intestine of young piglets by latching onto glycosphingolipids with A/H blood group determinants on type 1 core. We demonstrate the N-terminal domain of the F18 fimbrial subunit FedF to be responsible for ABH-mediated attachment and present its X-ray structure in ligand-free form and bound to A and B type 1 hexaoses. The FedF lectin domain comprises a 10-stranded immunoglobulin-like β-sandwich. Three linear motives, Q47-N50, H88-S90 and R117-T119, form a shallow glycan binding pocket near the tip of the domain that is selective for type 1 core glycans in extended conformation. In addition to the glycan binding pocket, a polybasic loop on the membrane proximal surface of FedF lectin domain is shown to be required for binding to piglet enterocytes. Although dispensable for ABH glycan recognition, the polybasic surface adds binding affinity in the context of the host cell membrane, a mechanism that is proposed to direct ABH-glycan binding to cell-bound glycosphingolipids and could allow bacteria to avoid clearance by secreted glycoproteins.