IOTL, the Portuguese court, under the leadership of Prince-Regent Dom João (the future João VI) fled from Lisbon to Rio de Janeiro in 1807, in order to avoid being captured by the troops of French general Jean-Andoche Junot.
However, what if they were forced to leave Portugal six years earlier...