Natural materials are renowned for exquisite designs that optimize function, as illustrated by the elasticity of blood vessels, the toughness of bone and the protection offered by nacre. Particularly intriguing are spider silks, with studies having explored properties ranging from their protein sequence to the geometry of a web. This material system, highly adapted to meet a spider's many needs, has superior mechanical properties. In spite of much research into the molecular design underpinning the outstanding performance of silk fibres, and into the mechanical characteristics of web-like structures, it remains unknown how the mechanical characteristics of spider silk contribute to the integrity and performance of a spider web. Here we report web deformation experiments and simulations that identify the nonlinear response of silk threads to stress--involving softening at a yield point and substantial stiffening at large strain until failure--as being crucial to localize load-induced deformation and resulting in mechanically robust spider webs. Control simulations confirmed that a nonlinear stress response results in superior resistance to structural defects in the web compared to linear elastic or elastic-plastic (softening) material behaviour. We also show that under distributed loads, such as those exerted by wind, the stiff behaviour of silk under small deformation, before the yield point, is essential in maintaining the web's structural integrity. The superior performance of silk in webs is therefore not due merely to its exceptional ultimate strength and strain, but arises from the nonlinear response of silk threads to strain and their geometrical arrangement in a web.