The Prophet SAAWS strictly prohibited the drawing of beings with souls; there are many hadiths in Bukhari and Muslim to support this.
Most people believe this commandment came after the angel Jibrael said he would meet the Prophet but then did not show up. Later, Aisha found a puppy hiding in their house and made it go away. Following this, the angel Jibrael appeared and explained to the Prophet that angels do not enter a house with pictures or dogs. Some angels bring the mercy of Allah and bring blessings to our homes; without them being able to enter our homes, they cannot bring mercy.
Aishah (May Allah be pleased with her) said: The Messenger of Allah (sallallaahu ’alayhi wa sallam) visited me after returning from a journey, and I had a shelf with a thin cloth curtain hanging over it and on which there were portraits. When he saw it, the colour of his face changed (because of anger) and he said, "O Aishah! the most grievous torment from Allah on the Day of Resurrection will be for those who imitate (Allah) in the act of His creation.'' `Aishah said: We tore it into pieces and made a cushion or two cushions out of that.
[Al-Bukhari and Muslim].
Muslim :: Book 24 : Hadith 5246
A'isha reported that Gabriel (peace be upon him) made a promise with Allah's Messenger (may peace be upon him) to come at a definite hour; that hour came but he did not visit him. And there was in his hand (in the hand of Allah's Apostle) a staff. He threw it from his hand and said: Never has Allah or His messengers (angels) ever broken their promise. Then he cast a glance (and by chance) found a puppy under his cot and said: 'A'isha, when did this dog enter here? She said: By Allah, I don't know. He then commanded and it was turned out. Then Gabriel came and Allah's Messenger (may peace be upon him) said to him: You promised me and I waited for you, but you did not come, whereupon he said: It was the dog in your house which prevented me (to come), for we (angels) do not enter a house in which there is a dog or a picture.
However, the Prophet did allow the drawing of inanimate objects such as trees and rocks -- anything which does not possess a soul.
Ibn Abbas (May Allah be pleased with them) said: I heard the Messenger of Allah (sallallaahu ’alayhi wa sallam) saying, "Every painter will go to Hell, and for every portrait he has made, there will be appointed one who will chastise him in the Hell.'' Ibn `Abbas said: If you have to do it, draw pictures of trees and other inanimate things.
[Al-Bukhari and Muslim].
The issue of photography has no definite position. There are two arguments:
- First, that photography would not fall into the category of pictures since it is an absolute copy of God's creation, and it would not be recreating God's creation.
- Second, that pictures and photography are the same thing and that a picture cannot fully depict God's creation no matter how accurate it becomes.
Both arguments have persuasive points to support them. However, there is a hadeeth that says if something seems haram, it is better to avoid it:
"Both legal and illegal things are obvious, and in between them are doubtful matters. So whoever forsakes those doubtful things lest he may commit a sin, will definitely avoid what is clearly illegal; and whoever indulges in these doubtful things bravely, is likely to commit what is clearly illegal."
One must also keep in mind that religion shouldn't be very complicated and getting too much into little details may cause more difficulty on you:
The Prophet said, “Religion is very easy and whoever overburdens himself in his religion will not be able to continue in that way. So you should not be extremists, but try to be near to perfection and receive the good tidings that you will be rewarded; and gain strength by worshiping in the mornings, the nights.”
And this is why many scholars have agreed that government photos and other vital situations where one must take a photo necessary for a person to own is permitted.
If it it is not apparent that something is haram, one should try to determine what is haram and halal in terms of moderation (and not be an extremist or to take every situation too lightly).