Insects are the only group of invertebrates that have evolved wings and flight. Two insect groups, the dragonflies and the mayflies, have flight muscles attached directly to the wings. Other insects have the flight muscles attached to the thorax, making it oscillate and indirectly causing the wings to beat. Some very small insects make use not of steady-state aerodynamics but of the Weis-Fogh clap and fling mechanism, generating large lift forces at the expense of wear and tear on the wings. Many insects can hover, maintaining height and controlling their position. Some insects such as moths have the forewings coupled to the hindwings so these can work in unison.
Insects first flew in the Carboniferous, some 350 million years ago. Wings may have evolved from appendages on the sides of existing limbs, which already had nerves, joints, and muscles used for other purposes. These may initially have been used for sailing on water, or to slow the rate of descent when gliding.
Unlike other insects, the wing muscles of the Ephemeroptera (Mayflies) and Odonata (dragonflies and damselflies) insert directly at the wing bases, which are hinged so that a small movement of the wing base downward, lifts the wing itself upward, very much like rowing through the air. Dragonflies and damselflies have fore and hind wings similar in shape and size. Each operates independently, which gives a degree of fine control and mobility in terms of the abruptness with which they can change direction and speed, not seen in other flying insects. This is not surprising, given that odonates are all aerial predators, and they have always hunted other airborne insects.
Other than the two orders with direct flight muscles, all other living winged insects fly using a different mechanism, involving indirect flight muscles. This mechanism evolved once, and is the defining feature (synapomorphy) for the infraclass Neoptera; it corresponds, probably not coincidentally, with the appearance of a wing-folding mechanism, which allows Neopteran insects to fold the wings back over the abdomen when at rest (though this ability has been lost secondarily in some groups, such as in the butterflies).