In order to address the issue of contraception, it should be clear that one of the major purposes of marriage in Islam is procreation, as it is the divinely appointed method of propagating human species on the face of the earth. Furthermore, Islam considers children as a source of blessing. The Prophet, therefore, exhorted his people to “marry and procreate.” Married couples, therefore, must not consider marriage simply as an avenue of sexual or emotional fulfillment and satisfaction, but also for purpose of procreation.
While procreation through marriage is highly recommended, Islam equally stresses the importance of rearing and nurturing children who are the future leaders and assets of the community and humanity. Parenting demands adequate care and attention on the part of parents, in the absence of which, children will simply become a burden. The Prophet (peace and blessings be upon him) said, “A strong believer is superior to a weak believer.”

In his well-known book, The Lawful and the Prohibited in Islam, the prominent Muslim scholar, Sheik Yusuf Al-Qaradawi, states:
“The preservation of the human species is unquestionably the primary objective of marriage, and such preservation of the species requires continued reproduction. Accordingly, Islam encourages having many children and has blessed both male and female progeny. However, it allows the Muslim to plan his family due to valid reasons and recognized necessities.
The common method of contraception at the time of the Prophet (peace and blessings be upon him) was coitus interruptus (withdrawal of the penis from the vagina just before ejaculation) thus preventing semen from entering the vagina. The Companions of the Prophet (peace and blessings be upon him) engaged in this practice during the period of the Qur’anic revelation. Jabir (may Allah be pleased with him) said, ‘We practiced coitus interruptus during the time of Allah’s Messenger (peace and blessings be upon him) while the Qur’an was being revealed.’ (Reported by al-Bukhari and Muslim)
Another version of this hadith, narrated by Muslim, reads, ‘We practiced coitus interruptus during the time of Allah’s Messenger (peace and blessings be upon him). He came to know about it, but he did not prohibit it.’
In a gathering at which `Umar was present, someone remarked, ‘Some say that coitus interruptus is a minor form of burying a child alive.’ To this `Ali replied, ‘This is not so before the completion of seven stages (of reproduction): being a product of the earth, then a drop of semen, then a clot, then a little lump of tissue, then bones, then bones clothed with flesh, which then become like another creation.’ ‘You are right,’ said `Umar, ‘May Allah prolong your life.’

Valid Reasons for Contraception:

The first valid reason for contraception is the fear that the pregnancy or delivery might endanger the life or health of the mother; the criterion of determining this possibility is experience or the opinion of a reliable physician. Allah Almighty says: ‘… And do not be cast into ruin by your own hands….’ (Al-Baqarah: 195) and, ‘… and kill not one another. Lo! Allah is ever Merciful unto you.’ (An-Nisa’: 29)
Another reason is the fear that the burden of children may hamper the family’s circumstances so much that one might accept or do something haram (unlawful) to satisfy their needs. Allah says: ‘… Allah desires ease for you, and He does not desire hardship for you…’ (Al-Baqarah: 185) and, ‘… It is not Allah’s desire to place a burden upon you…’ (Al-Ma’idah: 7)

Another valid reason is the fear that the new pregnancy or a new baby might harm a suckling child. The Prophet (peace and blessings be upon him) termed intercourse with a nursing mother, or rather the intercourse, which results in pregnancy while the mother is still nursing a baby, ‘Gheelah,’ emphasizing the fact that pregnancy would pollute the milk thus causing great harm to the suckling infant.
Since he was greatly concerned with the welfare of his Ummah, the Prophet (peace and blessings be upon him) dissuaded people from what would harm them.

Among the Prophet’s remarks on this issue is ‘Do not kill your children secretly, for Gheelah overtakes the rider and throws him from the horse.’ (Reported by Abu Dawud)
The Prophet (peace and blessings be upon him) did not, however, go so far as to prohibit intercourse with a nursing mother, as he noted that the Persians and Greeks, the two most powerful nations of his time, practiced it without any resulting injury to their children. Moreover, he feared that it would be a great hardship for husbands to abstain from their wives during the period of suckling, which may last up to two years. He said, ‘I intended to prohibit Gheelah, if not for the fact I noticed that the Persians and the Greeks suckled their children during pregnancy without any injury being caused to their children as a result.’ (Reported by Muslim)

Ibn Al-Qayyim, in comparing this hadith to the one quoted just before it ‘Do not kill your children secretly…’ says, ‘The Prophet (peace and blessings be upon him) saw that pregnancy harms the suckling infant in the same way as being thrown off a horse harms a rider: it is injurious, but not to the extent of killing the baby. He advised them to avoid intercourse leading to pregnancy while the woman is nursing an infant, but he did not prohibit it. He then intended to prohibit it in order to save the health of the suckling child if not that he considered the gravity of the danger this would cause the husband, especially the young ones, and the effect of that on society.

On balancing these matters, therefore, he preferred not to prohibit it. Moreover, he saw that in the two most powerful and populous nations of his time, (women) suckled their children during pregnancy without any negative effect on their strength or numbers, and accordingly he refrained from prohibiting it.’ (Ibn Al-Qayyim, Miftah Dar Al-Sa`adah, p. 620; also see Zad Al-Mi`ad, vol. 4 p. 26)

In our time, new methods of contraception are available which realize the objective intended by the Prophet (peace and blessings be upon him) that of protecting the suckling infant from any possible harm which may occur due to the pregnancy of his mother while at the same time avoiding the hardship to the husband in abstaining from sexual relations with his nursing wife.

From this we may conclude that from the Islamic point of view the ideal spacing between two children is thirty months, or, if one wants to nurse the baby for two full years, then thirty-three months.”

Sheikh M. S. Al-Munajjid, a prominent Saudi Islamic lecturer and author, adds:

“The answer to question of contraception is found in the following three points:

1. Giving birth is the right of both husband and wife, and neither one of them has the right to deprive the other from doing so.

2. It is prohibited to take any measure, which would permanently prevent pregnancy, or cause infertility. It is permissible, however, to use temporary birth control methods to delay pregnancy, as in the case of delaying pregnancy for the two years of breastfeeding the first child.

3. It is prohibited to use any birth control method which would harm the body, as the Prophet (peace and blessings be upon him) said: ‘Do not (impose) harm, nor (inflect) harm.’” [Quoted, with slight modification, from: Islam Q&A (www.islam-qa.com)]
You can also read:

Islamic View of Birth Control