In modern usage, gay is a term used to describe men who form romantic relationships or have sexual activity with other men. It may also be used to refer to men who are attracted to other men, romantically or sexually, whether such feelings are acted upon or not. The word is also sometimes used more inclusively to refer to the collective grouping of GLBT.
The ancient origins of "gay" are uncertain, with some etymologists tracing it to the Old High German gâhi ("swift"), though recent research supports wâhi ("pretty") as a more likely source. The Oxford English Dictionary (2nd edition) also notes that "the sense ‘slack, not closely fitting’, which exists in all the Romance languages (though not recorded very early in any of them) may possibly be of etymological significance." 
Its oldest English meaning, attested as early as 1310, is "disposed to joy and mirth", and was the most common use until the later part of the 20th Century. Its use in reference to homosexuality is not noted in standard dictionaries until 1935, when the word "geycat" was cited as prison slang for a homosexual boy; the independent form "gay" first appears in 1951. However, there are much earlier instances of the usage of "gay" in a similar context, one as early as 1889, in reference to the Cleveland Street Scandal in London, which involved a group of male prostitutes operating out of a men's club in the East End.
Many of these early usages were strongly pejorative, and were employed as insults; the gradual emergence of the gay community as a social and political force later led to the reclamation of the word in a positive sense in the wake of the gay movement; this may account for the relatively rapid change in the popular understanding of the word.
The English word "gay" was originally non-prejudicial, and could be applied to stylish objects as well as to people; it is, for instance, used to refer to various accoutrements of the Canterbury pilgrims by Geoffrey Chaucer, e.g. the Knight's Yeoman was said to have a "gay dagerre." The word is also a close relative of the Middle French and Provençal words gaya and gai, meaning, roughly, "joyful." Occitanian poets defined their poetic craft as lo gai saber, or the "joyful knowledge," and the philosopher Friedrich Nietzsche borrowed this phrase for his book, Das Fröliche Wissenschaft (1882), often translated as "The Gay Science."
Such a broadly poetic, and largely positive use of the word has faded from use in the centuries since, with its entry into political and cultural debates, whether pro- or anti-gay. This change in the word is reflected in such compound usages as gay-friendly or gay-bashing, as well as with blends such as gaydar (a homophonic pun on radar, referring to the supposed ability of gay men to detect other, possibly closeted, gay men's sexual orientation). In the early twenty-first century, the word "gay" has entered youth parlance as a synonym for "silly" or "ridiculous," a usage that some speakers insist is non-prejudicial, despite its past history of negative connotations.