Grains are individual crystals of a microstructure. Grains grow from nucleation sites, with primary phases of metallic alloys commonly growing as dendrites.
When grains meet during the solidification process they will produce a lattice mismatch as the orientations of the growing crystals will almost certainly be different. This mis-match forms a grain boundary.
Grain boundaries occur when growing grains meet.
Associated terms: Nucleation Site, Dendrite