The 25-year-old Movistar Team rider completed the 235km course, which started in Orbetello, in 5:58:17.
Caleb Ewan (Lotto Soudal) settled for second, with Diego Ulissi (UAE Team Emirates) completing the day’s podium.
“We tried to do last two kilometres hard to shake out the sprinters. We did that but then Carapaz jumped us from behind,” said Ulissi.
“Then Ewan went and he was strong too. There was not much I could do after that.”
Primoz Roglic (Jumbo-Visma) managed to keep hold of his overall race lead, with Simon Yates (Mitchelton-Scott) second and Vincenzo Nibali (Bahrain-Merida) third.
For the third day running, the stage breached the 200km mark. On tomorrow’s stage riders will tackle a 140km route from Frascati to Terracina.
View more provisional results below.
Stage four results
1. Richard Carapaz (ECU) Movistar Team 5:58:17
2. Caleb Ewan (AUS) Lotto Soudal
3. Diego Ulissi (ITA) UAE Team Emirates
4. Pascal Ackermann (GER) Bora-Hansgrohe
5. Florian Senechal (FRA) Deceuninck-QuickStep
6. Primoz Roglic (SLO) Jumbo-Visma
7. Valerio Conti (ITA) UAE Team Emirates
8. Miguel Angel Lopez (COL) Astana Pro Team +0:00:18
9. Arnaud Démare (FRA) Groupama-FDJ
10. Simon Yates (GBR) Mitchelton-Scott
39. Ryan Gibbons (RSA) Dimension Data +0:01:24
1. Primoz Roglic (SLO) Jumbo-Visma 18:19:20
2. Simon Yates (GBR) Mitchelton-Scott 0:00:35
3. Vincenzo Nibali (ITA) Bahrain-Merida 0:00:39
4. Miguel Angel Lopez (COL) Astana Pro Team 0:00:44
5. Diego Ulissi (ITA) UAE Team Emirates
6. Rafal Majka (POL) Bora-Hansgrohe 0:00:49
7. Bauke Mollema (NED) Trek-Segafredo 0:00:55
8. Damiano Caruso (ITA) Bahrain-Merida 0:00:56
9. Bob Jungels (LUX) Deceuninck-QuickStep 0:01:02
10. Davide Formolo (ITA) Bora-Hansgrohe 0:01:06
45. Ryan Gibbons (RSA) Dimension Data +0:03:54