The 50th-ranked Austrian converted his fourth match point as he broke Souza for a third time in the final set. After the second set, the match was interrupted for nearly an hour due to heavy rain.
In the second game of the match, Souza walked off the court after being warned by the umpire for taking too much time between his serves.
The Brazilian, who broke Thiem in the opening game, sat on his chair for several minutes but decided to play on after the umpire refused to call the supervisor during the game.
Thiem next plays Jiri Vesely of the Czech Republic, who defeated Jan-Lennard Struff of Germany 6-4, 6-4.
Riba trailed 6-2 in the tiebreaker before reeling off six straight points. Brown, who hit 14 aces, dropped serve at 5-5 in the second set.
Also, Maximo Gonzalez of Argentina beat eighth-seeded Pablo Carreno Busta of Spain 6-3, 4-6, 7-5; Albert Ramos-Vinolas of Spain rallied to beat Victor Galovic of Croatia 6-7 (5), 7-5, 6-2; and Andreas Haider-Maurer defeated Gerald Melzer 6-2, 7-6 (1) in an all-Austrian tie.