The story of the destruction of Sodom is told in Genesis 19, encompassing the entirety of that chapter. Sodom was the chief town of five on the plain of the Jordan River, being inhabited by the Canaanite clans. When Abraham travelled to the land of Canaan from Egypt at the command of God (with the promise that one day his descendents would own this land), he had been accompanied by his nephew Lot. The two men parted company as the land could not support them both together, with Lot travelling east to take up residence in Sodom and Abraham travelling West to live in Canaan.
The people of Sodom and Gomorrah were sinning against the Lord, and eventually He sent two angels to investigate their transgressions to see if the repute of their sin was as great as He had heard. When it transpired that it was, God destroyed all of the towns on the plain apart from one which Lot was allowed to escape to. Lot's wife, who was apparently unhappy to be leaving Sodom (she looked back) shared the fate of the inhabitants of the city - destruction, in her case by being turned into a pillar of salt. The city of Sodom had not had even ten righteous citizens within.
The polemical aspect of this Biblical story arises from the exact sin the people of Sodom are believed to be guilty of. When God's messengers arrived in Sodom to appraise the situation, they took up residence in the house of Lot. The King James Bible relates what happens next -
But before they lay down [to sleep, separately], the men of the city, even the men of Sodom, compassed the house round, both old and young, all the people from every quarter: And they called unto Lot, and said unto him, Where are the men which came in to thee this night? bring them out unto us, that we may know them.
"Know", of course, usually means sexual intercourse in this context. Some versions of the Old Testament, such as my New International Version, translate "know" simply as "have sex with". So on a simple reading it would seem the crime of Sodom was homosexuality or rape (these exist in all cities to an extent, but here all the men of the city were involved), especially as when offered two young maidens instead the men outside refused. This interpretation is favoured by the Qu'ran, in Sura 7 (commonly referred to as "The Heights") and Sura 26 ("The Poets") among others. For instance, 7:80 - 81:
"We also (sent) Lot: he said to his people: 'Do you commit lewdness such as no people in creation (ever) committed before you?'For ye practice your lusts on men in preference to women: ye are indeed a people transgressing beyond bounds.'
Or Sura 26:165-72, relating
Allah's destruction of Sodom following the request of Lot (the latter speaking) -
"Of all the creatures in the world, will ye approach males,"And leave those whom God has created for you to be your mates? Nay, ye are a people transgressing (all limits)!"
They said: "If thou desist not, O Lut! thou wilt assuredly be cast out!"
He said: "I do detest your doings."
"O my Lord! deliver me and my family from such things as they do!"
So We delivered him and his family,- all
Except an old woman who lingered behind.
But the rest We destroyed utterly.
At another point (Sura 11:79), "They said: "Well dost thou know we have no need of thy daughters: indeed thou knowest quite well what we want!"
However, such an interpretation is open to a number of criticisms (although it does show it was entrenched even by this early stage). Firstly, the Hebrew word for "man" (enoshe) translated here is usually translated as "mortal", meaning the focus would be on rape rather than homosexuality (but this raises other problems, as it was all the people, so homosexuality could be a component of a larger problem). Secondly, another interpretation presents itself that allows us to synthesize and make sense of the descriptions in the Old Testament on this matter with Jesus' message of love and tolerance in the New Testament, if hardly with the uncompromising version in the Qu'ran.
Just before the destruction of Sodom, God had visited Abraham in the desert and had been treated with great hospitality by him. In the desert, then as now, hospitality is a hugely important part of culture because a man left alone in the desert on his own cannot survive for long. Abraham washes the feet of his guest, and provides food and water to God and the two angels accompanying him. When the two angels go on to Sodom, they receieve no such good reception. Rather than this treatment, they are instead surrounded by a crowd of people with an intent to gang rape them. Homosexuality might not be a sin, but greeting guests, never mind angels, with a threat of homosexual gang rape most surely is.
Seen in this perfectly plausible way, the story of Sodom buttresses the message of the New Testament in two ways - God does not punish people for being homosexual, but he does punish them for not being respectful and helpful towards their fellow man. Although it must be admitted that the Bible is subject to many differing interpretation, this one surely is most consistent with the later command "If it is possible, as far as depends on you, live at peace with all men".
Sources
Holy Bible.
Holy Qu'ran (translated by Abdullah Yusuf Ali).
http://en.wikipedia.org/wiki/Sodom_and_Gomorrah