The present invention relates to an isolated DNA molecule encoding afagopyritol synthase. A method for producing a fagopyritol, an insulinmediator, an insulin mediator analogue, an insulin mediator homologue, or aninsulin mediator inhibitor is also described. The method includes providing afagopyritol synthase, providing a substrate comprising a galactosyl donor anda galactosyl acceptor, and combining the fagopyritol synthase with thesubstrate under conditions effective produce a fagopyritol, an insulinmediator, an insulin mediator analogue, an insulin mediator homologue, or aninsulin mediator inhibitor.