Though the cyclic forms of sugars are usually heavily favoured, hemiacetals in aqueous solution are in equilibrium with their open-chain forms. In aldohexoses this equilibrium is established as the hemiacetal bond between C-1 (the carbon bound to two oxygens) and C-5 oxygen is cleaved (forming the open-chain compound) and reformed (forming the cyclic compound). When the hemiacetal group is reformed, the OH group on C-5 may attack either of the two stereochemically distinct sides of the aldehyde group on C-1.  Which side it attacks on determines whether the α- or β-anomer is formed.
Anomerization of glycosides typically occurs under acidic conditions. Typically, anomerization occurs through protonation of the exocyclic acetal oxygen, ionization to form an oxocarbenium ion with release of an alcohol, and nucleophilic attack by an alcohol on the reverse face of the oxocarbenium ion, followed by deprotonation.