By the Grace of God (Latin Dei Gratia, abbreviated D.G.) is an introductory part of the full styles of a monarch historically considered to be ruling by divine right, not a title in its own right. In the United Kingdom, for example, the phrase was added to the royal style in 1521 and has continued to be used to this day. According to the "Royal Proclamation reciting the altered Style and Titles of the Crown" of May 29, 1953, the latest such change of royal title, Elizabeth II's present full title is
Elizabeth II, by the Grace of God of the United Kingdom of Great Britain and Northern Ireland and of Her other Realms and Territories Queen, Head of the Commonwealth, Defender of the Faith.
Originally, it had a literal meaning: the divine will was invoked—notably by Christian monarchs—as legitimation (the only one above every earthly power) for the absolutist authority the monarch wielded. This is also known as the divine right of kings, that is, the endorsement of God for the monarch's reign.
While the Christian Roman emperors during the late Dominate, especially in the East (as continued in Byzantium after the fall of Rome), came remarkably close to acting out the role of God's voice on earth, centralizing all power in their hands, e.g. reducing the Patriarch of Constantinople to their "(State) Minister of the Cult" and proclaiming their "universal" authority (in the Oriental tradition, as in Persia, but also in the original Muslim Caliphate), for most dynasties it would rather prove to be a never-ending battle up the hills of political resistance, both from rival power poles within their state (nobility, clergy; even within a dynasty) and from foreign powers claiming independence or even hegemony, usually constraining them in constitutional limitations (not necessarily written statutes, more often a matter of customary law and established privileges).
By custom, the phrase "by the Grace of God" is restricted to sovereign rulers; in the feudal logic, a vassal could not use it, because he held his fief not by the grace of God almighty, but by grant of a superior noble, (in)directly from the crown. Yet this did not stop kings to continue using it, even when some of them did homage to the pope (as viceregent of God) or another ruler (sometimes even mutually), on account of some (minor or "external") fief, or even for their actual principality, such as the Kingdom of Bavaria, a state of the Holy Roman Empire.
While the "incantation" of divine Grace became a prestigious style figure that few Christian monarchies could resist, it is not a literal carte-blanche from Heaven, but rather a consecration of the "sacred" mystique of the crown. Some of that survives even in modern constitutional monarchies and finds expression in most even mildly religious republics and dictatorships, where all power has been transferred to elected (party) politicians. In modern, especially recently (re-)founded monarchies, more realistic power reports (often crucially a voice in the succession and the purse strings) do in time find expression, sometimes even in abandoning "By the Grace of God", or rather, especially earlier, in the intercalation of compensatory phrases, such as "and the will of the people", or replacing the genitive "sovereign of X-place" by "sovereign of the X-inhabitants", quite meaningful where linked to the Enlightenment-notion of the "social contract", which means the nominal 'sovereign' is in fact potentially subject to national approval, without which a revolution against him can be legitimate.
The phrase was used in Luxembourg until 2000, when Henri, the current Grand Duke, decided to drop it. Like the use of the term "subject" for the citizens of a monarchy, "by the Grace of God" is a protocolary form that has survived the emancipation of the electorate from its once absolute rulers, who now rule only in name, but without direct political power. During the 20th century during the dictatorship of Francisco Franco in Spain, Spanish coins bore a legend identifying him as Francisco Franco, por la G. de Dios Caudillo de España ("by the G(race) of God, Leader of Spain").
Parallels exist in other civilizations, e.g. Mandate of Heaven of the Chinese empire, where for centuries the official decrees by the Emperors of China invariably began with the phrase 「奉天承運皇帝，詔曰」 which is translated as "The Emperor, by the Grace of Heaven, decrees".
Today, even though all western monarchies are constitutional, with all political power having passed to the people (by referendum or, generally, elections), the traditional phrase "by the grace of God" is still included in the full titles and styles of a number of monarchs. In Europe, monarchs still using the style are those of Denmark, Liechtenstein, the Kingdom of the Netherlands, and the United Kingdom.
In other Commonwealth realms, who share the same monarch with the United Kingdom, the style is used in Antigua and Barbuda, Australia, The Bahamas, Barbados, Belize, Canada, Grenada, Jamaica, New Zealand, Solomon Islands, St. Kitts and Nevis, St Lucia, St. Vincent and the Grenadines, and Tuvalu. Papua New Guinea does not use the style.
The phrase is not used in the monarchies of Belgium, Luxembourg (Jean, abdicated 2000), Monaco, Norway (Haakon VII, died 1957), and Sweden (Gustav VI Adolf, died 1973). In Spain, article 56(2) of the 1978 constitution, states that the title of the King of Spain is simply "King of Spain" (Rey de España) but that he "can use the titles that correspond to the Crown". As a result, the King of Spain may use "by the grace of God", but this is not used on official documents.
Similar concepts unrelated to and sometimes predating Christianity: