A battlement in defensive architecture, such as that of city walls or castles, comprises a parapet (i.e., a defensive low wall between chest-height and head-height), in which gaps or indentations, which are often rectangular, occur at intervals to allow for the launch of arrows or other projectiles from within the defences. These gaps are termed " crenels" (also known as carnels, or embrasures), and a wall or building with them is called crenellated; alternative (older) terms are castellated and embattled. The act of adding crenels to a previously unbroken parapet is termed crenellation.
The function of battlements in war is to protect the defenders by giving them something to hide behind, from which they can pop out to launch their own missiles. A defensive building might be designed and built with battlements, or a manor house might be fortified by adding battlements, where no parapet previously existed, or cutting crenellations into its existing parapet wall. A distinctive feature of late medieval English church architecture is to crenellate the tops of church towers, and often the tops of lower walls. These are essentially decorative rather than functional, as are many examples on secular buildings.
The solid widths between the crenels are called merlons. Battlements on walls have protected walkways ( chemin de ronde) behind them. On tower or building tops, the (often flat) roof is used as the protected fighting platform.
The term originated in about the 14th century from the Old French word batailler, "to fortify with batailles" (fixed or movable turrets of defence). The word crenel derives from the ancient French cren (modern French cran), Latin crena, meaning a notch, mortice or other gap cut out often to receive another element or fixing; see also crenation. The modern French word for crenel is créneau, also used to describe a gap of any kind, for example a parking space at the side of the road between two cars, interval between groups of marching troops or a timeslot in a broadcast. 
In medieval England and Wales a licence to crenellate granted the holder permission to fortify their property. Such licences were granted by the king, and by the rulers of the counties palatine within their jurisdictions, e.g. by the Bishops of Durham and the Earls of Chester and after 1351 by the Dukes of Lancaster. The castles in England vastly outnumbered the licences to crenellate.  Royal pardons were obtainable on the payment of an arbitrarily-determined fine by a person who had fortified without licence. The surviving records of such licences, generally issued by letters patent, provide valuable evidence for the dating of ancient buildings. A list of licences issued by the English Crown between the 12th and the 16th centuries was compiled by Turner & Parker and expanded and corrected by Philip Davis and published in The Castle Studies Group Journal. 
There has been academic debate over the purpose of licensing. The view of military-focused historians is that licensing restricted the number of fortifications that could be used against a royal army. The modern view, proposed notably by Charles Coulson, is that battlements became an architectural status-symbol much sought after by the socially ambitious, in Coulson's words: "Licences to crenellate were mainly symbolic representations of lordly status: castellation was the architectural expression of noble rank".   They indicated to the observer that the grantee had obtained "royal recognition, acknowledgment and compliment".   They could, however, provide a basic deterrent against wandering bands of thieves, and it is suggested that the function of battlements was comparable to the modern practice of householders fitting highly visible CC TV and burglar alarms, often merely dummies. The crown usually did not charge for the granting of such licences, but occasionally charged a fee of about half a mark. 
Battlements may be stepped out to overhang the wall below, and may have openings at their bases between the supporting corbels, through which stones or burning objects could be dropped onto attackers or besiegers; these are known as machicolations.
Battlements have been used for thousands of years; the earliest known example is in the fortress at Buhen in Egypt. Battlements were used in the walls surrounding Assyrian towns, as shown on bas reliefs from Nimrud and elsewhere. Traces of them remain at Mycenae in Greece, and some ancient Greek vases suggest the existence of battlements. The Great Wall of China has battlements.
In the European battlements of the Middle Ages the crenel comprised one-third of the width of the merlon: the latter, in addition, could be provided with arrow-loops of various shapes (from simply round to cruciform), depending on the weapon being utilized. Late merlons permitted fire from the first firearms. From the 13th century, the merlons could be connected with wooden shutters ( mantlets) that provided added protection when closed. The shutters were designed to be opened to allow shooters to fire against the attackers, and closed during reloading.
The Romans used low wooden pinnacles for their first aggeres ( terrepleins). In the battlements of Pompeii, additional protection derived from small internal buttresses or spur walls, against which the defender might stand so as to gain complete protection on one side.
Loop-holes were frequent in Italian battlements, where the merlon has much greater height and a distinctive cap. Italian military architects used the so-called Ghibelline or swallowtail battlement, with V-shaped notches in the tops of the merlon, giving a horn-like effect. This would allow the defender to be protected whilst shooting standing fully upright. The normal rectangular merlons were later nicknamed Guelph.
Many South Asian battlements are made up of parapets with peculiarly shaped merlons and complicated systems of loopholes, which differ substantially from rest of the world.  Typical Indian merlons were semicircular and pointed at the top, although they could sometimes be fake: the parapet may be solid and the merlons shown in relief on the outside, as is the case in Chittorgarh. Loopholes could be made both in the merlons themselves, and under the crenels. They could either look forward (to command distant approaches) or downward (to command the foot of the wall). Sometimes a merion was pierced with two or three loopholes, but typically, only one loophole was divided into two or three slits by horizontal or vertical partitions. The shape of loopholes, as well as the shape of merlons, need not have been the same everywhere in the castle, as shown by Kumbhalgarh. 
In Muslim and African fortifications, the merlons often were rounded. The battlements of the Arabs had a more decorative and varied character, and were continued from the 13th century onwards not so much for defensive purposes as for a crowning feature to the walls. They serve a function similar to the cresting found in the Spanish Renaissance architecture.
"Irish" crenellations are a distinctive form that appeared in Ireland between the 14th and 17th centuries. These were battlements of a "stepped" form, with each merlon shaped like an inverted 'T'.     
European architects persistently used battlements as a purely decorative feature throughout the Decorated and Perpendicular periods of Gothic architecture. They not only occur on parapets but on the transoms of windows and on the tie-beams of roofs and on screens, and even on Tudor chimney-pots. A further decorative treatment appears in the elaborate paneling of the merlons and that portion of the parapet walls rising above the cornice, by the introduction of quatrefoils and other conventional forms filled with foliage and shield.
- Larousse Dictionnaire Lexis de la Langue Française, Paris, 1979; Collins French Dictionary Robert
- Goodall 2011, p. 9.
- Davis 2007, pp. 226–245.
- Coulson 1982, p. 72.
- Coulson 1982, p. 83.
- Nossov, Konstantin S (2012). Indian Castles 1206–1526: The Rise and Fall of the Delhi Sultanate. Bloomsbury Publishing. p. 27. ISBN 978-1-84908-050-7.
- "Irish tower houses - Roaringwater Journal". roaringwaterjournal.com.
- Hodkinson, Brian J. (2011). "' Indeed a town of castles'; the castles of Limerick city" (PDF). North Munster Antiquarian Journal. 51: 53–60.
- Horning, Audrey J. (12 November 2018). Ireland in the Virginian Sea: Colonialism in the British Atlantic. UNC Press Books. ISBN 9781469610726 – via Google Books.
- "Irish castles - Roaringwater Journal". roaringwaterjournal.com.
- "Clara Castle, Kilkenny". Megalithic Ireland. Retrieved 2019-08-21.
- Balestracci, D. (1989). "I materiali da costruzione nel castello medievale". Archeologia Medievale (XVI): 227–242.
- Coulson, C. (1982). "Hierarchism in Conventual Crenellation". Medieval Archaeology. 26: 69–100. doi: 10.1080/00766097.1982.11735438.
- Davis, Philip (2007). "English Licences to Crenellate: 1199–1567" (PDF). The Castle Studies Group Journal. 20: 226–245.
- Goodall, John (2011). The English Castle. London: Yale Books. ISBN 978-0-300-11058-6.
- Luisi, R. (1996). Scudi di pietra, I castelli e l'arte della guerra tra Medioevo e Rinascimento. Bari.
- Coulson, Charles, 1979, "Structural Symbolism in Medieval Castle Architecture" Journal of the British Archaeological Association Vol. 132, pp 73–90
- Coulson, Charles, 1994, "Freedom to Crenellate by Licence - An Historiographical Revision" Nottingham Medieval Studies Vol. 38, pp. 86–137
- Coulson, Charles, 1995, "Battlements and the Bourgeoisie: Municipal Status and the Apparatus of Urban Defence" in Church, Stephen (ed), Medieval Knighthood Vol. 5(Boydell), pp. 119–95
- Coulson, Charles, 2003, Castles in Medieval Society, Oxford University Press.
- Coulson, Charles, Castles in the Medieval Polity - Crenellation, Privilege, and Defence in England, Ireland and Wales.
- King, D. J. Cathcart, 1983, Castellarium Anglicanum (Kraus)