By the 17th century, siege warfare was an exact art, the rules of which were so well understood wagering on the outcome and duration of a siege became a popular craze; the then enormous sum of £200,000 was alleged to have been bet on the outcome of the Second Siege of Limerick in 1691. Professional honour demanded a defence, but if they surrendered when 'a practicable breach' had been made, garrisons were given 'quarter'. They did so by 'beating the chamade'; it generally meant retaining their weapons, and receiving a pass to the nearest friendly territory. If a garrison continued their defence beyond this point, it did not apply, hence "No quarter;" the besiegers were then 'permitted' to sack the town, and the garrison often killed.
Black flags have been used to signify no quarter would be given, or requested; the best known example is the Jolly Roger used by pirates to indicate resistance meant death. Others include during the 1850 to 1864 Taiping Rebellion, as well as by irregular Confederate Army units in the US Civil War. At Tippermuir in 1644, Scots Covenanters used the battlecry "Jesus, and no quarter", signifying they would not take prisoners. It is suggested red flags were occasionally used for a similar purpose, but this does not appear to gave been common.
Under the modern laws of war, "it is especially forbidden ... to declare that no quarter will be given". This was established under Article 23(d) of the 1907 Hague Convention IV – The Laws and Customs of War on Land.
Since a judgment on the law relating to war crimes and crimes against humanity at the Nuremberg Trials in October 1946, the 1907 Hague Convention, including the explicit prohibition against declaring that no quarter will be given, is considered to be part of the customary laws of war and binding on all parties in an international armed conflict.
The term may originate from an order by the commander of a victorious army that they "will not quarter (house)" captured enemy combatants. Therefore, none can be taken prisoner and all enemy combatants must be killed. A second derivation, given equal prominence in the Oxford English Dictionary (OED), is that quarter (n.17) can mean "Relations with, or conduct towards, another" as in Shakespeare Oth. II. iii. 180, "Friends all..In Quarter, and in termes like Bride, and Groome." So "no quarter" may also mean refusal to enter into an agreement (relations) with an enemy attempting to surrender. The OED mentions a third possible derivation but says "The assertion of De Brieux (1672 Origines..de plusieurs façons de parler, 16) that it arose in an agreement between the Dutch and Spaniards, by which the ransom of an officer or private was to be a quarter of his pay, is at variance with the constant sense of the phrases give and receive quarter."
... giving no quarter can be construed that have the same meaning as taking no prisoners.