Praise be to Allaah.
It is not permissible to shave the beard, because according to saheeh ahaadeeth, the Messenger (peace and blessings of Allaah be upon him) commanded us to leave it alone and let it grow. He (peace and blessings of Allaah be upon him) told us that by leaving it alone and letting it grow, we would be differing from the Magians and mushrikeen, and he (peace and blessings of Allaah be upon him) had a thick beard. It is obligatory for us to obey the Messenger (peace and blessings of Allaah be upon him); following his example with regard to attitude and actions is one of the best deeds, because Allaah says (interpretation of the meaning):
“Indeed in the Messenger of Allaah (Muhammad) you have a good example to follow [al-Ahzaab 33:21]
“And whatsoever the Messenger (Muhammad) gives you, take it; and whatsoever he forbids you, abstain (from it) [al-Hashr :7]
“And let those who oppose the Messenger’s (Muhammad’s) commandment (i.e. his Sunnah legal ways, orders, acts of worship, statements) (among the sects) beware, lest some Fitnah (disbelief, trials, afflictions, earthquakes, killing, overpowered by a tyrant) should befall them or a painful torment be inflicted on them [al-Noor 24:63]
Imitating the kuffaar is one of the gravest of evil actions, and is one of the causes of being gathered with them on the Day of Resurrection, because the Prophet (peace and blessings of Allaah be upon him) said, “Whoever imitates a people is one of them.” If you are doing a job where you are required to shave your beard, do not obey them with regard to that, because the Messenger (peace and blessings of Allaah be upon him) said, “There is no obedience to any created being if it involves disobedience to the Creator.” If they oblige you to shave your beard, then leave that job where you are being forced to do something that angers Allaah. There are many other ways of earning a living, may Allaah be praised. Whoever gives up something for the sake of Allaah, Allaah will compensate him with something better than that.
May Allaah help you and make things easier for you. May He make us and you steadfast in His religion.
Majmoo’ Fataawa wa Maqaalaat Mutanawwi’ah li Samaahat al-Shaykh al-‘Allaamah ‘Abd al-‘Azeez ibn ‘Abd-Allaah ibn Baaz (may Allaah have mercy on him), vol. 8, p. 376
But if your military service is obligatory and they take you by force and shave your beard, then the sin is on them and not on you at all. And Allaah knows best.
Sheikh Muhammed Salih Al-Munajjid