A mainsail is a sail located behind the main mast of a sailing vessel.
On a square rigged vessel, it is the lowest and largest sail on the main mast.
On a fore-and-aft rigged vessel, it is the lowest and largest and often the only sail rigged aft of the main mast, and is controlled along its foot by a spar known as the boom. A sail rigged in this position without a boom is generally called a trysail, and is used in extremely heavy weather.
Traditional fore-and-aft rigs used a four-sided gaff rigged mainsail, sometimes setting a gaff topsail above it.
The modern Bermuda rig uses a triangular mainsail as the only sail aft of the mast, closely coordinated with a jib for sailing upwind. A large overlapping jib or genoa is often larger than the mainsail. In downwind conditions (with the wind behind the boat) a spinnaker replaces the jib.
Some mainsails are "full-batten" mainsails, meaning the batten extends all the way from the mast to the leeach of a sail. A partial batten extends from the mast partway to the leech. Battens enable the mainsail to project farther away from the mast. However, there is some cost associated with the battens themselves, "batten pockets" need to be sewn into the sail, and "batten cars" may be needed to allow the sail to be raised and lowered.
A mainsail may be fixed to the boom via slugs, cars, or a bolt-rope, or may be "loose-footed," meaning it is only attached at the tack and clew.
Before Nathanael Greene Herreshoff's invention of sail tracks and slides in the 1880s, mainsails were limited in height. Traditional mainsails were held against the mast by hoops that went the full way around the mast. This meant a traditional mainsail could be raised no higher than the first point a rope or wire was required to keep the mast upright.