He and his family were part of the Portuguese noble class, and when his remaining parent died in 1636, Ribafria and his three siblings were placed under the care of Antão de Almada, Count of Avranches.
Ribafria returned to Portugal the following year, and was immersed in the increasingly-prominent calls for the restoration of the Portuguese monarchy.
His guardian was one of the conspirators, and so Ribafria quickly joined the pro-independence faction inside Portugal, eventually being granted a command in the reformed Portuguese army.
During an engagement near the Spanish city of Badajoz in 1668, Ribafria became ill, and was forced to withdraw to the Portuguese town of Elvas.
Limping into battle and wielding a cane, Ribafria encouraged the garrison of Elvas to sally from the town and attack the Spanish besiegers.