An ancient Biblical tradition, a midrash, relates that the Canaanites wrote marriage contracts between man and man and woman and woman, and that this was one reason the land "vomited" them up in favor of the Israelites who took their place.It's one of those Biblical prohibitions that gets referred to, but doubted, because those who use it against homosexuality often forget to cite the source. So then those who are not against homosexuality claim it's a made up midrash ....
The main prohibitions on homosexuality in the Bible are Leviticus 18.22 and 20.13.
The midrash I believe that people are referring to is Sifra Acharei Mot, parashah 9:8.
It exists. It reflected the views of the Tannaim, wise men ... but ones who were writing in the century or so after the fall of the Temple. The Bible and midrashim say many things, and if we are to accept every word of them, then it would be ridiculous - they reflect the best learning of their day, but we have also moved on. Those who cite Leviticus against homosexuality often forget that the Bible is for slavery, for polygamy, against eating pork ...
When I'm having a bad day I watch episodes of The West Wing (I like to pretend everyone is that well intentioned). Jeb Bartlett put the case against relying too heavily on the Bible best in this scene:
I have no desire to be sold into slavery, so cannot see how anyone can justify condemning homosexuality using the same texts.
Update - Jim Davila has now added all the other suggestions for the midrashim here.