Homosexuality under Sharia is not only a sin, but a punishable crime against Allah. 
It is vital to understand the main point that homosexuality is legally prosecuted under Sharia at all times.
The punishment may vary in severity from a firm warning to the death penalty. However, habitual homosexuals are likely to be sentenced to death.
According to the Reliance of the Traveller, the manual of Sharia law, homosexuality concerns everyone, no matter whether the person is a Muslim, a non-Muslim subject of the Islamic State, or someone who has left Islam. 
Homosexuality is condemned in both the Koran and the Hadith of Bukhari and Muslim. However, neither of these texts prescribe precise punishment for men, while the Koran dictates that women proved to be lesbian are to be left in a closed house until they die.
There are some hadiths (examples of Mohammed’s speech and actions) from other canonical collections which make the death penalty clear as a form of punishment :
The Reliance of the Traveller, 012.2, p17.3, assigns stoning to death as the punishment.
In the Sharia legal system, homosexuality is punished according to the principle of Taazir. Taazir means that the punishment should prevent the crime as well as reform the offender.
So there is a dual purpose - to deter and to reform. 
Possible punishments for homosexuality include: admonition, reprimand, threats, boycott, public disclosure (shaming), fines and seizure, imprisonment, banishment, and flogging.
The habitual homosexual can be put to death if lesser punishments have not worked and criminal is regarded as an habitual offender whose wickedness can only be stopped by the death penalty.  The decision is left entirely to the judge. Other preventative punishments can also be used if they do not contradict Islamic law. 
"And (We sent) Lot when he said to his people: What! do you commit an indecency which any one in the world has not done before you? Most surely you come to males in lust besides females; nay you are an extravagant people. And the answer of his people was no other than that they said: Turn them out of your town, surely they are a people who seek to purify (themselves). So We delivered him and his followers, except his wife; she was of those who remained behind. And We rained upon them a rain; consider then what was the end of the guilty."
If any of your women are guilty of lewdness [lesbianism], then bring in four of you as witnesses against them. If they admit their guilt, then shut them up in their houses until they die or until Allah makes some other way for them. If two of your men are guilty of an indecent act [homosexuality], punish both of them. If they ask for forgiveness and change their ways, then leave them alone, for Allah is forgiving and merciful!
Do you approach males among the worlds and leave what your Lord has created for you as mates? But you are a people transgressing.” They said, “If you do not desist, O Lot, you will surely be of those evicted.”
Would ye really approach men in your lusts rather than women? Nay, ye are a people (grossly) ignorant! But his people gave no other answer but this: They said, ―Drive out the followers of Lut from your city: these are indeed men who want to be clean and pure!‖ But We saved him and his family, except his wife; her We destined to be of those who lagged behind. And We rained down on them a shower (of brimstone) and evil was the shower on those who were admonished (but heeded not).
And (remember) Lut: behold, he said to his people: ―Ye do commit lewdness, such as no people in Creation (ever) committed before you. Do ye indeed approach men, and cut off the highway? - and practice wickedness (even) in your councils?‖ But his people gave no answer but this: they said: ―Bring us the Wrath of Allah if thou tellest the truth.
Narrated by Abdullah ibn Abbas: The Prophet said: If you find anyone doing as Lot's people did, kill the one who does it, and the one to whom it is done.
Sunan Abu Dawood, 38:4447, Al-Tirmidhi, 15:1456, Ibn Maajah, 20:2561
Narrated Abdullah ibn Abbas: If a man who is not married is seized committing sodomy he will be stoned to death.
Sunan Abu Dawood, 38:4448
The legal penalty is obligatorily imposed upon anyone who fornicates or commits sodomy (A: provided it is legally established when they;
(a) have reached puberty;
(b) are sane;
(c) and commit the act voluntarily;
no matter whether the person is a Muslim, non-Muslim subject of the Islamic state, or someone who has left Islam.
The Reliance of the Traveller o12.1
If the offender is someone with the capacity to remain chaste, then he or she is stoned to death (def: o12.6), someone with the capacity to remain chaste meaning anyone who has had sexual intercourse (A: at least once) with their spouse in a valid marriage, and is free, of age, and sane. A person is not considered to have the capacity to remain chaste if he or she has only had intercourse in a marriage that is invalid, or is prepubescent at the time of marital intercourse, or is someone insane at the time of marital intercourse who subsequently regains their sanity prior to committing adultery. If the offender is not someone with the capacity to remain chaste, then the penalty consists of being scourged (def: o12.5) one hundred stripes and banished to a distance of at least 81 km./50 mi. for one year.
The Reliance of the Traveller o12.2
In more than one place in the Holy Koran, Allah recounts to us the story of Lot's people, and how He destroyed them for their wicked practice. There is consensus among both Muslims and the followers of all other religions that sodomy is an enormity. It is even viler and uglier than adultery.
The Reliance of the Traveller p17.1
Allah Most High says:
"Do you approach the males of humanity, leaving the wives Allah has created for you?
But you are a people who transgress" (Koran 26:165-66).
The Reliance of the Traveller p17.2
The Prophet (Allah bless him and give him peace) said:
(1) "Kill the one who sodomizes and the one who lets it be done to him."
(2) "May Allah curse him who does what Lot's people did."
(3) "Lesbianism by women is adultery between them."
The Reliance of the Traveller p17.3
 The Punishment of homosexuality in Islamic contemporary world (Malaysia, Iran, Pakistan and Saudi Arabia as a case study); prepared by Shafini Abdul Azeez Bello, Islamic University Malaysia.
 The Relliance of the Traveller, o12.1, p.610.
 Policing Muslim Communities, Comparative International Context; Hakeem, F.B.; Haberfield, M.R.; Verma, A.; 2012, IX, 146 p. 12 illus., Hardcover ISBN: 978-1-4614-3551-8.
 Sunan Abu Dawood, 38:4447, 38:4448.