At Her Majesty’s pleasure (His Majesty when appropriate, sometimes abbreviated to Queen’s or King’s Pleasure) is a legal term of art derived from the fact that the authority for all governance stems from the Crown. Originating from the United Kingdom, it is now used throughout the Commonwealth realms, though usually in a traditional manner.
In realms where the monarch is represented by a viceroy, the phrase may be modified to be at the Governor’s pleasure, since the governor-general, governor, or lieutenant governor is the Queen’s personal agent in the country.
In nations under a presidential form of government, the phrase has been adapted to suit the title of the chief executive.
The term is also used to describe detainment in prison or a psychiatric hospital for an indefinite length of time; a judge may rule that a person be “detained at Her Majesty’s pleasure” for serious offences or based on a successful insanity defence. This is sometimes used where there is a great risk of re-offending; however, it is most often used for juvenile offenders, usually as a substitute for life sentencing (which would naturally be much longer for younger offenders).
For example, Britain’s Powers of Criminal Courts (Sentencing) Act 2000 states:
“Where a person convicted of murder or any other offence the sentence for which is fixed by law as life imprisonment appears to the court to have been aged under 18 at the time the offence was committed, the court shall (notwithstanding anything in this or any other Act) sentence him to be detained during Her Majesty’s pleasure.”