Sousa, 72nd placed in the world ranking ATP, won in three sets against 34th placed Tiafoe by 6-3, 6-7 (3-7) and 7-6 (7-4), after three hours and one minute.
Sousa, 30, is to face Federer, world No. 3 and the third seed in Rome’s tournament.
Federer beat Sousa in 2016 in the semi-finals in Halle, Germany, by 6-7 (8-10), 6-4 and 6-2.
The round of 32 between the two players is to take place on Wednesday.