Unfortunately the first part of your question is impossible to answer, as it is predicated on the assumption that homosexuality (or heterosexuality, for that matter) existed in ancient or prehistoric times. To clarify, of course same-sex sexual behaviors existed, but the seemingly basic idea of a "sexual orientation," or that sexual behavior/gender preference was something around which identity could be organized, is in fact a very modern concept.
As to the second part of your question, that is also somewhat challenging to answer. There is no simple timeline, nor can we make simplistic comparisons and generalizations about different cultural traditions. But if we take your question at its most basic, and confine it to one place (the US, although a very slight extrapolation to a few other Western nations might be allowed) - "at what point did [the United States] start to become anti-gay?" - I would say that the period from the mid-late 19th century though the Second World War would be a good place to situate the beginnings of homophobia.
The contemporary understandings of hetero/homosexuality come into being in the mid 19th century; it is only after this creation of difference that homophobia could exist. This period was a time of significant shifts in how people understood and organized gender, sex, and sexuality. Once the idea that sexuality informed identity had entered the consciousness, and heterosexuality had become a dominant social organizing force as a kind of "default" or "unmarked" sexuality, homosexuality became "othered." However, it's not until WWII that the significant societal shifts of the previous 60+ years fully crystallized into what we would now understand as "anti-gay" attitudes.
Homosexual relationships in Japan were (from most sources) not common, however they did exist. In most homosexuality-related articles of pre-modern Japan it is not presented as something that happened often, rather it was kept quiet - you didn't parade around announcing who you were sleeping with, you just did it. More notable accounts of homosexual relationships exist between samurai and their 'squires' - pederast relationships between a mentor and a student. These were more open and acknowledged by the public, as the fathers of these boys would essentially sign away their children for a period of time to serve under the samurai. However, these relationships would still count for the minority. These relationships stemmed from pederasty between buddhist monks and their proteges or acolytes, which was even more common within monasteries.
Similar to China, homosexuality for the most part has always been legal in Japan, with no recorded punishments (to my knowledge) for homosexual relationships, so this would not have been an issue raised in feudal Japan. Homosexuality would have (at the very least) not been seen as a distasteful act either, as many paintings and woodblock prints exist (this one is a good example of shudo) depicting homosexual relationships. Also, similar to China, the social stigma of negativity surrounding homosexuals never truly developed into a concern in society until the Westernisation of said countries from the 19th century onwards.
In China, homosexuality was seen similarly to how it was seen in Japan, with Buddhist temples not differentiating between homosexual or heterosexual relationships. Some sources even claim that emperors themselves engaged in multiple homsexual relationships:
Confucianism did much the same, focusing more on social philosophy. The laws regarding homosexuality were directed more towards prostitution than to mature relationships. In fact, recorded opposition to homosexuality appeared later on when Christian and Islam writers that reflected their own attitudes reached China.
Other sources:
How the Japanese became foreign to themselves - Hein, P.
I can't really speak to your second question, but I can talk about the first one. In my limited research into this subject, I have found sources that say that homosexuality in Babylon and possibly other ancient Mesopotamian civilizations such as the Akkadians or Assyrians had a very open minded ideas about homosexuality and other things some would deem "morally dubious" today.
Vern Bullough talks about this in the Journal of Sex Research, saying that "...In Babylonia, there was little or no distinction between what was morally right and ritually proper. In fact, it seems that the gods were far more angry when their subjects ate ritually impure food than when they oppressed widows and orphans. His anger would better be appeased by a ritual offering than with a reformed life. This causes complications in studying sexual life because this is where Mesopotamian standards differed most form our own. ..."
He talks at length about the practice of ritual prostitution. This includes men as well. Her says later that men sometimes did take part in homosexual prostitution. This is where it gets muddied; the sources don't translate well into English, and most of the translations were done by men. Whether intentional or not, this results in not much information on female homosexuality. Regardless, most of the research found references to homosexuality only in temples.
To get back on point, homosexuality and other "deviant" sexual practices did happen in Babylon, Sumer and most likely in Assyrian and Akkadian civilizations. What we know is that this was almost definitely a rare "sacred prostitution" type deal, but homosexuality was "practiced" out in the open, and there seemed be very little societal reservations about this. It is still important to note, that the Mesopotamian ideals of morals and ideals are somewhat different from ours.
http://www.jstor.org/discover/10.2307/3811696?uid=3739832&uid=2&uid=4&uid=3739256&sid=21105171340613