The following is from a work-in-progress called The Qur'an: a Book Report, in which I read each surah of the Qur'an and write about what I learn.
This surah references events that were said to have happened in the hear of Muhammad's birth (570 C.E.), when Abraha, a Christian ruler of Yemen, amassed a large army (including war elephants, like in The Lord of the Rinigs) to attack Mecca, destroy the sacred Ka'aba, and divert pilgrims to a Christian cathedral in their homeland.
According to this surah, Abraha's army was defeated with God's help: "Do you [Prophet] not see how your Lord dealt with the army of the elephant? Did He not utterly confound their plans? He sent flocks of birds against them, pelting them with pellets of hard-baked clay (also, like the eagles from The Lord of the Rings): He made them [like] cropped stubble."
This story is meant to encourage the believers in Mecca that God will also protect them.