The Existence of Abrogating and Abrogated Verses in the Qur'an
Among the verses in the Qur'an containing orders or laws, there are verses that abrogate verses previously revealed and acted upon. These abrogating verses are called nasikh and those whose validity they terminate are called mansukh.
For example, at the beginning of the Prophet's mission, Muslims were ordered to cultivate peace and friendship with the people of the Book, "Forgive and be indulgent (towards them) until God gives command," [II:109]. Some time later, fighting was allowed and the order to establish peace was abrogated: Fight against such as those who have been given the Book but who believe not in God nor the last day, and do not forbid that which God has forbidden by His messenger, and follow not the religion of truth ... [XI:29]
The common notion of abrogation, that is, a cancelling of one law or code by another, is based on the idea that a new law is needed because of a mistake or shortcoming in the previous one. It is clearly inappropriate to ascribe a mistake in law-making to God, Who is perfect, and whose creation admits of no flaws.
However, in the Qur'an, the abrogating verses mark the end of the validity of the abrogated verses because their heed and effect was of a temporary or limited nature. In time the new law appears and announces the end of the validity of the earlier law. Considering that the Qur'an was revealed over a period of twenty-three years in ever-changing circumstances, it is not difficult to imagine the necessity of such laws. It is in this light that we should regard the wisdom of abrogation within the Qur'an: And when We put a revelation in place of (another) revelation and God knows best what He reveals - they say: you are just inventing it. Most of them do not know. Say: The Holy Spirit (Gabriel) has revealed it from your hand with truth and as a guidance and good news for those who have surrendered (to God) [XVI:101-102]..