Luís Alves' grandfather, José Joaquim, was a Portuguese military officer who had emigrated in 1767 to Brazil. He settled in the city of Rio de Janeiro, capital of both the Rio de Janeiro captaincy and of Brazil. He had neither noble rank nor noble ancestry and lacked patrons in an environment in which advancement depended upon exchanges of favors and family connections. Having fought against the Spaniards on Brazil's southern frontiers, he secured a place for himself in Rio de Janeiro's upper class when he married a member of a local and influential family.