County of Portugal separated from Kingdom of Galicia
The County of Portugal (Portuguese: Condado de Portugal, Condado Portucalense, Condado de Portucale; in documents of the period the name used was Portugalia) refers to two successive medieval counties in the region around Braga and Porto, today corresponding to littoral northern Portugal, within which the identity of the Portuguese people formed.  The first county existed from the mid-ninth to the mid-eleventh centuries as a vassalage of the Kingdom of Asturias and the Kingdom of Galicia and also part of the Kingdom of León, before being abolished as a result of rebellion. A larger entity under the same name was then reestablished in the late 11th century and subsequently elevated by its count in the mid-12th century into an independent Kingdom of Portugal.Second county
In 1093, Alfonso VI nominated his son-in-law Raymond of Burgundy as count of Galicia, then including modern Portugal as far south as Coimbra, though Alfonso himself retained the title of king over the same territory. However, concern for Raymond's growing power led Alfonso in 1096 to separate Portugal and Coimbra from Galicia and grant them to another son-in-law, Henry of Burgundy, wed to Alfonso VI's illegitimate daughter Theresa. Henry chose Guimarães as the base for this newly formed county, the Condado Portucalense, known at the time as Terra Portucalense or Província Portucalense, which would last until Portugal achieved its independence, recognized by the Kingdom of León in 1143. Its territory included much of the current Portuguese territory between the Minho River and the Tagus River.Count Henry continued the Reconquista in western Iberia and expanded his county's dominions. He was also involved in several intrigues inside the Leonese court together with his cousin Raymond and sister-in-law Urraca of Castile, in which he supported Raymond's ascension in return for promises of autonomy or independence for Portugal. In 1111 the Muslims conquered Santarém. When Count Henry died in 1112, the population of the County of Portugal, including the powerful families, favored independence. Henry's widow, Theresa, took the reins on behalf of her young son, and allied herself with Galician nobility in order to challenge her sister queen Urraca's dominance and briefly used the title Queen. However, she was defeated by Urraca in 1121 and forced to accept a position of feudal subservience to the Leonese state. Her own son, Afonso Henriques, took the reins of the government in 1128 after routing his mother's forces in the Battle of São Mamede, near Guimarães. After this battle, he began to exhibit a seal with a cross and the word "Portugal", and he continued to win battles, supported by the nobles of Entre-Douro-e-Minho. Nevertheless: