We discuss the ability of the planned Euclid mission to detect deviations from general relativity (GR) using its extensive redshift survey of more than 50 million galaxies. Constraints on the gravity theory are placed measuring the growth rate of structure within 14 redshift bins between z= 0.7 and 2. The growth rate is measured from redshift-space distortions, i.e. the anisotropy of the clustering pattern induced by coherent peculiar motions. This is performed in the overall context of the Euclid spectroscopic survey, which will simultaneously measure the expansion history of the Universe, using the power spectrum and its baryonic features as a standard ruler, accounting for the relative degeneracies of expansion and growth parameters. The resulting expected errors on the growth rate in the different redshift bins, expressed through the quantity fσ8, range between 1.3 and 4.4 per cent. We discuss the optimization of the survey configuration and investigate the important dependence on the growth parametrization and the assumed cosmological model. We show how a specific parametrization could actually drive the design towards artificially restricted regions of the parameter space. Finally, in the framework of the popular ‘γ parametrization’, we show that the Euclid spectroscopic survey alone will already be able to provide substantial evidence (in Bayesian terms) if the growth index differs from the GR value γ= 0.55 by at least ∼0.13. This will combine with the comparable inference power provided by the Euclid weak lensing survey, resulting in Euclid’s unique ability to provide a decisive test of modified gravity.