Medieval men's underpants were fairly loose drawers known as braies, breeks, or breeches. Varying in length from upper-thigh to below the knee, braies could be closed with a drawstring at the waist or cinched with a separate belt around which the top of the garment would be tucked. Braies were usually made of linen, most likely in its natural off-white color, but they could also be sewn from finely woven wool, especially in colder climes.
In the Middle Ages, braies were not only used as underwear, they were frequently worn by laborers with little else when doing hot work. Those depicted here fell well below the knees, but were tied to the wearer's waist to keep them out of the way.
No one really knows whether or not medieval women wore underpants. Since the dresses medieval women wore were so long, it could be very inconvenient to remove underwear when answering nature's call; on the other hand, some form of snug underpants could make life a little easier once a month. There's no evidence one way or the other, so it's entirely possible that, at times, medieval women wore loincloths or short braies. We just don't know for sure.
Update: A discovery made in Austria indicates that women probably wore garments much like modern-day brassieres and underpants at least as far back as the 15th century. See your Guide's blog, Exciting find in medieval underwear, for more information.