The phrase Her Majesty's Government (His Majesty's Government during the reign of a male monarch) is a formal term referring to the government of a Commonwealth realm or one of constituent provinces, states or territories. In use since at least the height of the British Empire, the phrase has been inherited and integrated into the countries that emerged from that polity.
In the British Empire, the term His (or Her) Majesty's Government was originally only used by the imperial government in London. As the Empire developed into the Commonwealth of Nations, the former Dominions came to be seen as realms of the sovereign equal in status to the United Kingdom, and, from the 1920s and 1930s, the form His Majesty's Government in... began to be used by the United Kingdom and Dominion governments to differentiate between independent jurisdictions, such as His Majesty's Government in the Irish Free State. Colonial, state, and provincial governments, on the other hand, continued to use the lesser title Government of [region/territory], and eventually the phrase used in the former Dominions altered to mirror that of the UK, becoming, for example, Her Majesty's Australian Government.
The term is employed in order to signify that the government of a Commonwealth realm or, less commonly, a division thereof, belongs to the reigning sovereign, and not to the cabinet or prime minister, though individual governments (also known as ministries) may be identified by reference to the prime minister who chairs the cabinet at the time; the Attlee government or Manley government, for example.
Today, however, most Commonwealth realm governments, other than that of the UK (where the abbreviation HMG is frequently used), have reverted to predominantly using the form Government of [region], with Her Majesty's Government being typically employed in formal circumstances. Within federations, such as Canada and Australia, disambiguation between federal, provincial, or state governments is sometimes required—for instance, a 1989 Canadian Supreme Court decision refers to "Her Majesty's Government for the Province of Nova Scotia"—while in foreign affairs a national qualifier can be employed to differentiate between the governments of different monarchies; Her Britannic Majesty's Government for example.