We provide a systematic and updated discussion of a research line carried out by our group over the last few years, in which gravity is modified at cosmological distances by the introduction of nonlocal terms, assumed to emerge at an effective level from the infrared behavior of the quantum theory. The requirement of producing a viable cosmology turns out to be very stringent and basically selects a unique model, in which the nonlocal term describes an effective mass for the conformal mode. We discuss how such a specific structure could emerge from a fundamental local theory of gravity, and we perform a detailed comparison of this model with the most recent cosmological datasets, confirming that it fits current data at the same level as ΛCDM.Most notably, the model has striking predictions in the sector of tensor perturbations, leading to a very large effect in the propagation of gravitational wave (GWs) over cosmological distances. At the redshifts relevant for the next generation of GW detectors such as Einstein Telescope, Cosmic Explorer and LISA, this leads to deviations from GR that could be as large as 80%, and could be verified with the detection of just a single coalescing binary with electromagnetic counterpart. This would also have potentially important consequences for the search of the counterpart since, for a given luminosity distance to the source, as inferred through the GW signal, the actual source redshift could be significantly different from that predicted by ΛCDM. At the redshifts relevant for advanced LIGO/Virgo/Kagra the effect is smaller, but still potentially observable over a few years of runs at target sensitivity. arXiv:2001.07619v1 [astro-ph.CO] 21 Jan 2020 4 Conclusions 66 A Difficulties of alternative nonlocal models 68 -1 -2 The Lichnerowicz operator is defined by E µν,ρσ ≡ 1 2, where 2 = η µν ∂µ∂ν is the flat-space d'Alembertian. We use the signature ηµν = (−, +, +, +) and MTW [14] sign conventions. 3 We assume here 3 + 1 spacetime dimensions. See [13] for the corresponding equations in d + 1 spacetime dimensions, with d generic.