Glycosyltransferase that acts on alpha-linked mannose of N-glycans and O-mannosyl glycans. Catalyzes the transfer of N-acetylglucosamine (GlcNAc) to the beta 1-6 linkage of the mannose residue of GlcNAc-beta1,2-Man-alpha on both the alpha1,3- and alpha1,6-linked mannose arms in the core structure of N-glycan (By similarity). Also acts on the GlcNAc-beta1,2-Man-alpha1-Ser/Thr moiety, forming a 2,6-branched structure in brain O-mannosyl glycan (PubMed:22715095). Plays an active role in modulating integrin and laminin-dependent adhesion and migration of neuronal cells via its activity in the O-mannosyl glycan pathway. N(4)-{beta-D-GlcNAc-(1->2)-[beta-D-GlcNAc-(1->4)]-alpha-D-Man-(1->3)-[beta-D-GlcNAc-(1->2)-alpha-D-Man-(1->6)]-beta-D-Man-(1->4)-beta-D-GlcNAcl-(1->4)-beta-D-GlcNAc}-L-asparaginyl-[protein] + UDP-N-acetyl-alpha-D-glucosamine = H(+) + N(4)-{beta-D-GlcNAc-(1->2)-[beta-D-GlcNAc-(1->4)]-alpha-D-Man-(1->3)-[beta-D-GlcNAc-(1->2)-[beta-D-GlcNAc-(1->6)]-alpha-D-Man-(1->6)]-beta-D-Man-(1->4)-beta-D-GlcNAcl-(1->4)-beta-D-GlcNAc}-L-asparaginyl-[protein] + UDP 3-O-[N-acetyl-beta-D-glucosaminyl-(1->2)-alpha-D-mannosyl]-L-seryl-[protein] + UDP-N-acetyl-alpha-D-glucosamine = H(+) + O(3)-{N-acetyl-beta-D-glucosaminyl-(1->2)-[N-acetyl-beta-D-glucosaminyl-(1->6)]-alpha-D-mannosyl}-L-seryl-[protein] + UDP 3-O-[N-acetyl-beta-D-glucosaminyl-(1->2)-alpha-D-mannosyl]-L-threonyl-[protein] + UDP-N-acetyl-alpha-D-glucosamine = H(+) + O(3)-{N-acetyl-beta-D-glucosaminyl-(1->2)-[N-acetyl-beta-D-glucosaminyl-(1->6)]-alpha-D-mannosyl}-L-threonyl-[protein] + UDP Protein modification; protein glycosylation. Present in brain (at protein level) (PubMed:16413118). Predominantly expressed in hippocampus, superficial layers of the brain cortex, striatum, nucleus accumbens, a subset of nuclei in the thalamus, inferior colliculus, brain stem and cerebellum (PubMed:16413118, PubMed:22715095). Brains from mutant mice display defective biosynthesis of O-mannosyl glycans (PubMed:22715095). Mutant mice that lack both Mgat5 and Mgat5b display no visible changes in brain anatomy, but their brains display defective biosynthesis of both O-mannosyl glycans and N-linked glycans (PubMed:22715095). Belongs to the glycosyltransferase 18 family.