Metformin is a prescription-only oral medication used to treat type 2 diabetes. It works by helping to bring your blood sugar levels under control.