Halaal and Haraam Earning (Hadith No. 1770)

Bismillah.
Volume 3, Book 34, Number 275:
Narrated Abu Huraira (radiallaahu `anhu):
The Prophet (sallallaahu `alayhi wasallam) said, "A time will come when one will not care how one gains one's money, legally or illegally."

How did the Companions earn their livelihood? [Examples of halaal earning]

  • Trade, as in the case of Abu Bakr al-Siddeeq, ‘Uthmaan ibn ‘Affaan and ‘Abd al-Rahmaan ibn ‘Awf (may Allaah be pleased with him).
  • Agriculture, whether they owned farmland or worked on the land; many of the Muhaajireen and Ansaar were involved in this.
  • Skilled crafts, such as smithery, carpentry and so on.
  • Jobs that were connected to the state, such as teaching, collecting zakaah, judging and so on.
  • Earnings acquired through jihad, such as war booty

Haraam Earning:

Some jobs are haraam in and of themselves, such as working in riba-based banks and places where alcohol is sold. Some may be haraam because of things in the work-place that are contrary to sharee’ah, such as mixing between men and women, or because it is stipulated that one should wear haraam clothing or do other things that are contrary to sharee’ah, such as shaving the beard. It is not permissible for the Muslim to do either type of job.
Jobs of the second type vary in the degree to which they are haraam. The one which incurs the greatest burden of sin is that which involves writing down or recording riba (usury), then that which involves selling or manufacturing haraam things, then that in which the workplace environment is haraam. The last category should not be taken lightly, because it has an impact on the religious commitment and conduct of the worker, especially the fitnah of women which was the first fitnah of the Children of Israel and is the most harmful fitnah for the Muslim man, as our Prophet Muhammad(peace and blessings of Allaah be upon him) told us. 
If mixing between men and women is something that happens in your country and you can hardly find any job that is free of that, and you think that your being in that job will be beneficial and that you will be able to put a stop to some of that evil and reduce some of it, and you will be able to advise the employees who are under your authority, enjoining them to do what is good and forbidding them to do what is evil as much as you can, and you can take precautions and measure which will help you avoid the fitnah of women – such as hastening to get married if you are not married, not looking at them or being alone with them – and if the work requires you to sit with some of the female employees you can leave the door of the office open and not sit close to them and so on... then we think that your being present in the workplace and achieving some of the interests of sharee’ah and reducing some evils, is better than keeping the workplace devoid of the righteous and leaving it to those who do not pay any attention to religion or to the rulings of sharee’ah, so that these evils become more widespread and it becomes more difficult to fight them. How many teachers and university professors have taught in mixed institutions and Allaah has benefited many through them, and warded off a great deal of evil.  We hope by Allaah’s grace that you will be one of them. 
However, if you think, after taking the job, that you cannot adhere to your religious commitment and that you are being pulled into haraam gradually, then you have no choice but to leave that job immediately. If a person gives up something for the sake of Allaah, Allaah will compensate him with something better than it, as the Messenger (peace and blessings of Allaah be upon him) said.