Margrave was originally the medieval title for the military commander assigned to maintain the defense of one of the border provinces of the Holy Roman Empire or of a kingdom. That position became hereditary in certain feudal families in the Empire, and the title came to be borne by rulers of some Imperial principalities until the abolition of the Empire in 1806 (e.g., Margrave of Brandenburg, Margrave of Baden). Thereafter, those domains were absorbed in larger realms or the titleholders adopted titles indicative of full sovereignty.
Etymologically, the word "margrave" (Latin: marchio, c. 1551) is the English and French form of the German noble title Markgraf (Mark, meaning "march", added to Graf, meaning "Count"); it is related semantically to the English title "Marcher Lord". As a noun and hereditary title, "margrave" was common among the languages of Europe, such as Spanish and Polish.
A Markgraf (margrave) originally functioned as the military governor of a Carolingian march, a medieval border province. Because the territorial integrity of the borders of the realm of a king or emperor was essential to national security, the vassal (whether a count or other lord) whose lands were on the march of the kingdom or empire was likely to be appointed a margrave and given greater responsibility for securing the border.