This article relies largely or entirely on a single source. (April 2013)
Brazil was initially a colony of Portugal, established during the Portuguese colonization of the Americas. Historians are not sure on the precise moment when Brazilians developed a local nationalism, distinct from the Portuguese one. In some cases it is pointed to the discovery itself, in others it is attributed to the explorations of the bandeirantes or the South American theater of the Dutch-Portuguese War in the 17th century.
Still, the first cases of a strong nationalist sentiment emerged in the 19th century. The white Brazilian-born colonial oligarchy developed sentiments against the colonial system, and manifested hostility to the Portuguese authorities. There were local conspiracies to secede from Portugal as early as in 1789, but the Independence of Brazil took place in the 1820s, after the transfer of the Portuguese Court to Brazil during the Napoleonic Wars. Brazilians had a desire for self-governance and resented that wealth of the nation was taken to Portugal.
After independence, Brazilian nationalism maintained its anti-Portuguese sentiment, expanding to anti-British and anti-Spanish American sentiments (specially against the countries of the Río de la Plata Basin, Argentina, Paraguay and Uruguay), shaping an anti-foreign nationalism. The anti-Portuguese sentiment was in fact a common sentiment across all of Brazil, and helped to keep the country unified during the late colonial periods and the first chaotic years after independence. The Brazilian monarchy was also a unifying factor, as the majority of the elite accepted the authority of the kings and feared the consequences of a potential revolution of their slaves. The elite envisioned a country of white peoples, but the slaves, mulattoes, and mestizos composed almost the two-thirds of the Brazilian population. For this end, they encouraged European immigration, to increase the number of white people.
The anti-Portuguese sentiment also led to an increased use of the French language, in detriment of the Portuguese language. France was seen at the time as a model of civilization and progress. The literary nationalism began in the 1840s with the works of José de Alencar, who used French literary models to describe the regions and social milieus of Brazil. Nationalist literary works became more complex in the second half of the 19th century.