Just like the title states, is it haraam to take medicine that contains alcohol?
No, it's not haraam to take medicine that contains alcohol, but haram to use alcohol itself as a medicine.
That's because when melted with water (or medicine) in small amounts (for example, 5% alcohol), alcohol will dissolve and the result will not cause person to be drunk, which is why alcohol is prohibited (causing one to be drunk), and once the prohibition reason is gone, then prohibition itself is gone, too.
Here is a quotation from one major fiqh book (of the Shafei school):
محل الخلاف في التداوي بها – يعني بالخمر - بصرفها ، أما الترياق المعجون بها ونحوه مما تستهلك فيه ، فيجوز التداوي به عند فقد ما يقوم مقامه ، مما يحصل به التداوي من الطاهرات ، كالتداوي بنجس ، كلحم حية ، وبول , ولو كان التداوي بذلك لتعجيل شفاء ، بشرط إخبار طبيب مسلم عدل بذلك ، أو معرفته للتداوي به
It's disputed whether it's allowed or prohibited to use pure alcohol in treatment. But for antidote (and the like) that it's melted with and dissolved, then it's allowed to use it in treatment if there's no (alcohol-free) immaculate replacements that are usually used in treatment. It's like when treating with impure things, like snake meat, or urine. It's allowed to use it in treatment even it that was only to hurry up the healing. But under the condition of telling an upright muslim doctor about that.
Mughni Al Muhtaj By Al-Khateeb Al-Sharbini (may Allah be merciful to him), 518/5.
Also there are fatwas about this issue:
Q: There are a lot of medicine that contains different amounts of alcohol that varies between 0.01% and 25%, and most of them are medicine for cold, sore throat, cough, and other popular diseases. The medicine that contains alcohol is about 95% of the medicine in this field, so obtaining alcohol-free medicine becomes very difficult or impossible, can we get these (alcohol-containing) medicine?
A: A muslim patient can get medicine that contain percentage of alcohol if there is no alcohol-free replacement available, at the prescription of an honest muslim doctor.
Using pure alcohol in treatment is not allowed in any case, because The Prophet (PBUH) said: (Allah didn't put your treatment in what he prohibited you) Sahih Bukhari, and The Prophet (PBUH) said: (Allah created medicine for every disease so you have to get treatment, and don't use haraam (things) in treatment) Ibn Dauood in his sunan, and Ibn Assuni, and Abu Na'im. And he (The Prophet) told Tariq bin Swaid when he asked him about using alcohol in treatment: (It's not a treatment, but a disease) Ibn Majah in his sunan, and Aub Na'im.
It's allowed to use in treatment medicine that contains percentage of alcohol that dissolve and are important for the medical industry and have no replacement. Under the prescription of an upright doctor. It's also allowed to use alcohol as an outside antiseptic for wounds, and germs killer, and in (outer) kreams.
The Islamic Fiqh Council recommends medical industry companies and pharmacists in Islamic countries, and medicine importers, to make the best they can to exclude alcohol from medicine and alcohol containing medicine, and use alternative medicine.
The Council also recommends doctors to avoid prescribing alcohol-containing medicine.
Hope that's clarifying enough.
P.S: sorry for typos and bad translation, any edit is most welcome :)
Short answer is : Doing so knowingly is haram.
Alcohol in general is haram. Based on your question you probably already knew that. Reference is [2:219]
They ask you about wine and gambling. Say, "In them is great sin and [yet, some] benefit for people. But their sin is greater than their benefit." And they ask you what they should spend. Say, "The excess [beyond needs]." Thus Allah makes clear to you the verses [of revelation] that you might give thought.
If this is the only medicine that can treat your ailment, with no non-alcoholic medicine available, you probably can use it to treat yourself based on the necessity principle, however do consult a scholar if you can.
You can eat forbidden foods due to necessity. Reference: [2:173]
He has only forbidden to you dead animals, blood, the flesh of swine, and that which has been dedicated to other than Allah . But whoever is forced [by necessity], neither desiring [it] nor transgressing [its limit], there is no sin upon him. Indeed, Allah is Forgiving and Merciful.
A translated fatwa from my country (Malaysia, Shafi'i):
(I'm not going to translate the word Arak here, as the english word for alcohol is used for the drink as well as the chemical. In context, the word Arak here means a drink that is used as an intoxicant.)
All Arak contains alcohol. Not all alcohol is a component of Arak. Alcohol from the process of Arak creation is haraam and najis, but alcohol that is not from the process of Arak creaion is not najis, but haram to drink.
Drinks that are created from the same process of Arak creation, whether it contains a little alcohol or the alcohol is removed is haraam.
Drinks that are not intended to be Arak or intoxicants and not created in the same method are halal.
Tapai is halal.
Alcohol as a byproduct of food creation is not a najis and can be eaten.
Medicine and perfumes that contain alcohol are permitted.
(Personally disagree with point 2 as other scholars have said that non-alcoholic beer and wine vinegar is halal, but just translating)
Another less formal source on this:
If alcohol is derived from grapes or dates, it will be haram and impure. If it is from anything else besides dates and grapes and it does not intoxicate directly or through a mixture, then it is permissible.
Some research turns up this point of view as a common one in other parts of the world, but this is the most formal version I could find.
I am no scholar, nor am I a sheik or imam. I'm just a Muslim whom is blessed with understanding.
At the time of our beloved prophet (pbuh), alcohol along with other intoxicants were banned in Islam unto today. Why would anything which Allah (stw) commanded the prophet (pbuh) to be banned be legal in islam now? There are forms of fruits and other foods which the prophet consumed which scientists are now discovering the benefit. Not everyone is educated and understanding to know about health, but it's simple by following the sunnah. Meaning you can pray dua, and eat and live like the prophet (pbuh) and that's it.
On YouTube, there are videos on foods of the prophet you can even research the benefits of the food. Alcohol in medication are simply to speed up the blood circulation the body will speed up causing the medication to work. But still the alcohol acts like alcohol. Drink medication without alcohol and exercise or sleep with a blanket the heat will cause the blood to be thinned and the medication will work just fine. I'm not a doctor either. I'm just blessed by Allah.