Most insects are capable of adhesion to smooth surfaces like glass. On the tips of their legs ants and other insects have a specialized appendage called a tarsus. The tarsus includes claws for locomotion on rough terrain, as well as a flexible pad, called an arolium, for adhesion to smooth surfaces. The surface of the arloium varies within the insects: In flies and beetles it is covered with fine hairs, while on ants, bees, roaches, and grasshoppers it is a flat flexible cuticle. The arolium is coated with viscous secreted fluids allowing it to work like a wet suction cup.

Scanning electron micrograph of a cockroach tarsus, showing hooks and the arolium. Adapted from Clemente & Federle, 2008.
As the ant plants its foot and applies an inward-dragging force on its tarsus, the arolium passively expands, increasing suction contact with the surface (see below). It is by this mechanism that ants generate the suction-adhesion forces required to carry heavy loads over smooth surfaces. This passive expansion is especially advantageous since it automatically prevents detachment in case of sudden jostling. In addition, if the ant only applies a little pressure on the arolium it does not expand as significantly, allowing the ant to move at a brisker pace when not carrying a heavy load.

Light micrographs of a weaver ant tarsus planting on a smooth surface. The arolium pad automatically expands as the appendage is dragged on the surface. Adapted from Federle, 2002
Weaver ants, like the one in the photo at top, create elaborate woven hives out of plant leaves. Their gathering routs bring them over soil, up bark, and frequently across the undersides of smooth leaves. Therefore they have evolved a tarsus the can grip with both claws and suction in order to carry their heavy payloads home.
References:
- Endlein, T., & Federle, W. (2007). Walking on smooth or rough ground: passive control of pretarsal attachment in ants Journal of Comparative Physiology A, 194 (1), 49-60 DOI: 10.1007/s00359-007-0287-x
- Clemente, C., & Federle, W. (2008). Pushing versus pulling: division of labour between tarsal attachment pads in cockroaches Proceedings of the Royal Society B: Biological Sciences, 275 (1640), 1329-1336 DOI: 10.1098/rspb.2007.1660
- Federle, W. (2002). An Integrative Study of Insect Adhesion: Mechanics and Wet Adhesion of Pretarsal Pads in Ants. Integrative and Comparative Biology, 42 (6), 1100-1106 DOI: 10.1093/icb/42.6.1100