The Viceroyalty of Brazil refers, in narrow scope, to office of viceroy of the Portuguese colonial State of Brazil and, in broad scope, to the whole State of Brazil during the historic period when its governors had the title of "viceroy". The term "viceroyalty" however never officially designated the title of the colony, which continued to be designated "state". Until 1763, the title "Viceroy" was occasionally granted to some governors of Brazil who were members of the high nobility, with the remaining keeping the title "governor-general". From around 1763, the title "viceroy" became permanent, so being granted to all governors. The position of viceroy was abolished, when the Portuguese court transferred to Brazil in 1808, with the State of Brazil becoming directly administered by the Portuguese Government seated in Rio de Janeiro.
Since the 17th century, the title of "viceroy" was granted occasionally to some governors of the State of Brazil, who were members of the Portuguese high nobility, with the first being Jorge de Mascarenhas, marquis of Montalvão, who assumed the office in 26 May, 1640. The remaining, kept the title of "governor-general".
Around 1763, at the same time that the capital of the State of Brazil was transferred from Salvador to Rio de Janeiro, the title "viceroy" became permanent and, since then, granted to all governors of the State. The driving force for the move was the then tiny village of São Paulo dos Campos de Piratininga, and its capital was made São Sebastião do Rio de Janeiro as a result of the Emboabas' War against Portuguese recent arrivals and colonizers from Bahia, and the consequent shift of economic power to the gold-producing Minas dos Matos Gerais: São Sebastião do Rio de Janeiro was the port where the gold was sent to Portugal, and consequently the point of contact between metropolis and colony.
In 1775, the remaining states of the Portuguese America (Maranhão and Grão-Pará) were integrated in the State of Brazil, becoming under the authority of its viceroy, the capital maintained in Rio de Janeiro.