One of my friend, who is very punctual in offering Namaaz, has seen offering namaaz sometimes even when the sun is setting. He is of the view that offering Namaaz at sun set or sun rise time is not a sin and it might be just a makrooh. I told him that offering prayer at sun set or sun rise time is not allowed and it might be a sin also. Because to have distinction with non-muslims, it has not been allowed to offer namaaz at this time.
Please tell me whether offering of prayers(Namaaz) at sun set or sun rise time is makrooh or a sin and why?
Praise be to Allaah.
It is mustahabb to pray naafil prayers at all times, except at the times when praying is not allowed. These times are from after Fajr prayer until the sun has risen to the height of a spear; from noon time until after the sun has passed its zenith, which is at mid-day for about five minutes before the sun reaches its zenith; and from after ‘Asr prayer until the sun sets. What is meant is the prayer which each person does by himself; once he has prayed ‘Asr it becomes haraam for him to pray until the sun has set, except in specific cases, when it is not haraam. See Question # 306.
The reason why it (prayer at these times) is not allowed is so as to avoid any resemblance to the kuffaar who prostrate to the sun when it rises as a greeting to it and to express their joy, and they prostrate to it when it sets as a farewell to it. The Prophet (peace and blessings of Allaah be upon him) was keen to put a stop to all things that may lead to shirk, or that might involve any resemblance to the mushrikeen. With regard to the prohibition on praying when the sun is near its zenith, this is because this is the time when the Fire of Hell is intensified, as was reported from the Prophet (peace and blessings of Allaah be upon him), so we should refrain from praying at these times.
from the fatwas of Shaykh Ibn ‘Uthaymeen, 1/354