King in Prussia was a title used by the Electors of Brandenburg from 1701 to 1772. Subsequently they used the title King of Prussia.
The House of Hohenzollern ruled Brandenburg as Prince-Electors, and were subjects of the Holy Roman Emperor. Since 1618, the Electors of Brandenburg had also ruled the Duchy of Prussia, which lay outside of the empire, in a personal union. The dual state was known as Brandenburg-Prussia. The Duchy of Prussia was originally a fief that the dukes held of the King of Poland, of whom they were vassals, until the Treaties of Labiau (1656) and Bromberg (1657), with which Frederick William, the Great Elector, had achieved full sovereignty from the Polish Crown. In 1701 Elector Frederick III wanted to show his greatness by adopting the title king.
In return for Hohenzollern assistance in the War of the Spanish Succession and support for the Habsburg candidate in the subsequent election, Emperor Leopold I allowed Frederick to crown himself "King in Prussia".
Legally, Frederick was only an elector in his domains within the borders of the empire; he was only king in his former duchy. Even though Brandenburg was still legally part of the empire and ruled in personal union with Prussia, it soon came to be treated as a de facto part of Prussia.
On 17 January 1701, Frederick dedicated the royal coat of arms, the Prussian black eagle with the motto "suum cuique" imprinted. On 18 January, he crowned himself and his wife Sophie Charlotte in a baroque ceremony in Königsberg Castle.