War elephants played a critical role in several key battles in antiquity, but their use declined in the Middle Ages. With the spread of firearms in the early modern period, military elephants were restricted to non-combat engineering and labour roles, and some ceremonial uses.