Depends who you talk to. The age most people choose is 6 months but they can be weaned as early as 2 or as soon as they start to eat solid food on a consistant basis. Despite what many might think, the mare's milk has very little nutrition by this point and she is nothing more than a security blanket for the foal.
As for how to do it, make sure the baby is turned out with atleast one other horse and far enough away that he can't hear or see mama.
I weaned my colt as five months as he wasnt eating milk at all and he was really well developed for his age. We put him in my pasture with a stall by himself. His mom could come to the gate but she actually truely prefered not too after the first three or four days. She was glad to get rid of him. The reason I decided to have him weaned a bit earlier was because he was using her to stay away from me so I couldnt work with him. I kept him up for about a month altogether. Once I had him in the stall by himself for a while I was able to slowly start halter breaking him and lead training him. Once he was listening to me on a leadline and I was able to get him easily with the halter I started letting him out into the pasture by himself. He was able to see the other horses when they were near the gate but he got used to being by himself when he needs to be. He's never been very herd bound thanks to this.
Two months is way too young to wean. They need mom teaching them manners. I personally think five months is a good age but to me definitely not younger than four months of age. Six months may or may not be too long.
It really just depends on the individual horse and foal. Generally we try to wean our foals at 5 months, but if they're dragging their dams down or seem to be really well developed for their age and are eating almost only feed, then we'll occasionally wean at 4 months old.
We have a 40 acre property that is divided by a creek/bridge, so what we do is we wean by bringing both the mare and foal over to our weaning area, letting them stay there for a week to accustom the foal to it's new 'home', then one day we just calmly walk the dam away and put her back in her old pen. They're far enough away from eachother that they can't see or call to eachother and by this time the foal is already used to it's new home. Its the least stressful way for both of them, and we do a lot of work with both prior to weaning on learning to leave eachother for short times (30 minutes to an hour) so that the dam can be worked starting when the foal is a month old.
If we have more than one foal that year, when its time to move the dams and foals to the weaning pasture, we generally put them together so that the foals get to know eachother and wean them all at the same time. If we only have one, we introduce an uncle gelding or a retired broodmare into the pen while the dam is still there and when we take the dam out, we leave the gelding or mare to 'babysit' the weanling until its about 8 months old. At this point we feel like most foals are old enough to be adapted into a larger herd setting, and we introduce both the foal and gelding into a herd together.