In my defens God me defend

In my defens God me defend (Scottish Gaelic: Ann an Dia mo dhìon dìon mi) is the motto of both the royal coat of arms of the Kingdom of Scotland and royal coat of arms of the United Kingdom used in Scotland. Contemporary versions of the royal arms show an abbreviated motto, in the form of in defens or, where English is used as an alternative, in defence. The motto appears above the crest of the arms, in the tradition of Scottish heraldry.
Adopted during the reign of the Stewart dynasty, and certainly in use by the reign of James IV (1488–1513), In my defens God me defend was originally the only motto associated with Scotland's royal arms, with versions appearing in both truncated and abbreviated forms; In my defens, for example, having been adopted for the royal arms of James IV. (An embroidered wall hanging depicting these arms is displayed in the Great Hall at Stirling Castle). Later versions of the arms which feature the abbreviated form in defens include the armorial by Sir David Lyndsay of the Mount, which appears in his Register of Scottish Arms (1542).
The motto is also associated with an old Scots prayer, of which there are several versions where In my defens God me defend appears as the opening line, including:
And:
Also, in the form of a couplet:
Another variation of the phrase, appearing as Be my defens God me defend forever more, is to be found engraved upon a number of traditional Ballock knives, with one particular example (dated 1624) now forming part of the Arms and Armour collection of the Art Institute of Chicago.
During the reign of Charles II (1660–1685), the royal arms used in Scotland were augmented with the inclusion of the Latin motto of the Order of the Thistle, the highest chivalric order of the Kingdom of Scotland. The motto of the Order of the Thistle, Nemo me impune lacessit, appears on a blue scroll overlying the compartment. (Previously, only the collar of the Order of the Thistle had appeared on the arms.)
The addition by King Charles of Nemo me impune lacessit ensured that the blazon of his royal arms used in Scotland complemented that of his royal arms used elsewhere, in that two mottoes were displayed. The blazon used elsewhere had included the French motto of the arms, Dieu et mon droit, together with the Old French motto of the Order of the Garter, the highest chivalric order of the Kingdom of England. The motto of the Order of the Garter, Honi soit qui mal y pense, appears on a representation of the garter surrounding the shield. Thenceforth, the versions of the Royal arms used in Scotland and elsewhere were to include both the motto of the arms of the respective kingdom and the motto of the associated order of chivalry.
The rules governing heraldry and armorial achievements in England have possibly resulted in a degree of confusion as to the status of the mottoes associated with both the royal coat of arms of Scotland and those of the United Kingdom used in Scotland. In English heraldry the motto is placed beneath the shield, whereas in Scottish heraldry the motto is placed above the crest. Appearing beneath the shield may have led to the conclusion that Nemo me impune lacessit is the motto of the royal arms, whereas historical evidence coupled with the conventions of heraldry in Scotland would suggest that In my defens God me defend is the motto of the royal arms and therefore the motto of Scotland itself.
The motto In defens not only appears on the royal arms, but also, in conjunction with the crest of the Royal arms, upon the logo of both the Crown Office and Procurator Fiscal Service and the General Register Office for Scotland.