The ABO blood group system is determined by what type of glycosyltransferases are expressed in the body.
The ABO gene locus expressing the glycosyltransferases has three main allelic forms: A, B, and O. The A allele encodes 1-3-N-acetylgalactosaminyltransferase that  bonds α-N-acetylgalactosamine to D-galactose end of H antigen, producing the A antigen. The B allele encodes 1-3-galactosyltransferase that joins α-D-galactose bonded to D-galactose end of H antigen, creating the B antigen. In case of O allele the exon 6 contains a deletion that results in a loss of enzymatic activity. The O allele differs slightly from the A allele by deletion of a single nucleotide - Guanine at position 261. The deletion causes a frameshift and results in translation of an almost entirely different protein that lacks enzymatic activity. This results in H antigen remaining unchanged in case of O groups.
The combination of glycosyltransferases by both alleles present in each person determines whether there is an AB, A, B or O blood type.