Rocks stores energy and release which results is earthquakes. Stress is a force which is exerted on an object and in Earth scenario these forces are tectonic forces. Tectonic stress is developed by the movement of plates. Every object has elastic limit where it can come back to its original position, however in the case of rocks when stress is applied it deforms according to the force direction. When stress is released it bears the shape of deformation and do not comes back to its original position, this is called plastic deformation. By this deformation earthquakes does not occur. In other condition where deformation is elastic, so every object has its limit beyond which it ruptures. Under elastic deformation beyond limit it ruptures brittle and the elastic energy stored by rocks is released and surrounding rocks elastically comes back to its original position and this creates vibrations and travel through crust which are earthquakes. Earthquakes are also produced when already present fault block slip along each other.
Waves travel through Earth's surface and reflect back to surface or refract through interior. Waves that travel through the rocks are called seismic waves and seismic waves can be produced both by earthquakes and explosions. Study of earthquakes and getting evidence of Earth's interior based on seismic waves. Earthquake produces different types of seismic waves,body waves generated from the rupture point which is called focus. The Earth's surface above the focus point is called epicenter. Body waves carry energy from the focal point of the earthquake and then from the epicenter surface waves initiates. Surface waves are just like waves on the surface of water.
Body waves are of two types which travel through the Earth. P waves and S waves. P wave is also called compressional wave because of its nature as an elastic wave causes alternate compression and expansion of the rock. P waves travel with a speed of 4-7 km in Earth's crust and about 8 km per second in the uppermost part of the mantle. P waves are primary waves because they are first to reach the surface as its velocity is huge.
The second type is S waves which a shear waves and it moves just like water waves. S waves motion can be illustrated when you tie a rope and on the other end jerk it up and down. S waves is slow wave that travel at speed of 3-4 km per second in the crust.
P waves can travel in the molten rocks but S waves can only pass through solid rocks because of the less bounding between liquid and gases.
Surface waves travel much slowly than the body waves and there are two types of surface waves. Rayleigh wave which motion is similar to that of ocean wave, up and down. the other is Love wave and its motion is side to side (left right).