The City and the Pillar is the third novel by American writer and essayist Gore Vidal. First published in 1948, it sparked a public scandal for being the first book by an American author to deal quite openly with homosexuality. Twenty years later, Vidal changed the ending to what he had originally in mind, no longer having to defer to the wishes of his publisher, in The City and the Pillar Revised.

The novel has two underlying themes: Vidal's appeal for a lifting of the laws that banned homosexual sex acts in the US at the time. And a feeling of alienation from what he thinks heterosexual people would perceive as typical homosexual characteristics, that is, feminine and unmanly behavior. Instead, Vidal sees the group of men who desire homosexual sex as considerably more differentiated, including men who are married and do not display obvious signs of their sexual preferences.

The plot centers on Jim Willard, a handsome youth in Virginia in the late 1930s, who is also a very good tennis player. When his best friend Bob Ford, one year his senior, is about to leave high school, the two make a camping trip into the woods. Both are elated to be in each other's company and after some moaning from Bob how difficult it is to get the local girls to have sex with him, the two have sex several times, even though Bob thinks this is not a "normal" thing for two men to do.

Jim, to whom it has already occurred that girls do not appeal to him as much, hopes Bob can stay and is crushed when Bob is insistent on joining the merchant marine. The next seven years of Jim's life will be an odyssey, at the end of which he hopes to be happily reunited with Bob.

Jim decides he wants to go to sea too and becomes a cabin boy on a cruise ship after going to New York to look for work. Another seaman on his ship, Collins, goes out with him in Seattle, but is more interested in a double date with two girls than sex with Jim. The date is a disaster for Jim, who must realize that he is unable to drink enough to overcome being repelled by the female body. When he finally storms out, Collins calls him a queer, which causes him to think about this possibility.

He quits his job, fearing another confrontation with Collins, and becomes a tennis instructor at a hotel in Los Angeles. One of the bellboys, Leaper, whose advances he has spurned previously, introduces him to the circle around the mid-thirties Hollywood actor Ronald Shaw, who immediately takes interest in Jim. Eventually, Jim moves in with Ronald, even though he is not really in love with him.

Their affair is ended when Jim meets the writer Paul Sullivan at a party, who is in his late twenties. Jim is drawn to Paul because he seems so different from the other, more stereotypical homosexuals he meets at Hollywood parties, even having married once (although that marriage was later annulled).

When Shaw learns of their relationship, Jim is quite happy to move with Paul to New Orleans. Again, he is not in love with Paul but with his boyhood pal, but he considers Paul adequate for the time being. Paul however, needing some pain in his relationships for artistic inspiration, introduces Jim to Maria Verlaine, who seems to specialize in seducing homosexuals, hoping his relationship will end in a suitably tragic way. Together, the three go to Yucatán, where Maria has made an inheritance. Jim does feel vaguely attracted to Maria, but he is unable to perform sexually. All the same, for Paul even an imagined affair of his boyfriend with a woman is as painful as he had hoped and warrants a breakup.

In the meantime, World War II has started in Europe and Paul and Jim are determined to go to New York to enlist in the Army. This of course also means their separation. Jim gets transferred to a Colorado Air Force base, where his sergeant is clearly sexually interested in him. But Jim has set his sights on a young corporal. Unfortunately, the corporal does not seem to like him in that way, even though the sergeant later seems to succeed with the corporal.

Due to the cold Colorado weather, Jim contracts rheumatoid arthritis and is eventually discharged from service. He goes back to New York, where he meets Maria and Ronald again. Ronald has been forced to marry a lesbian by studio executives to uphold his public image and tries unsuccessfully to become a stage actor. He also introduces Jim to his local friends like an effeminate millionaire. Jim begins frequenting gay bars to find sexual relief. Later, he meets Paul at a party and the two start an open relationship, not because of passion, but out of loneliness.

When Jim finally goes home for Christmas, he learns that his father is dead and (more alarming to him) that Bob has married. Hoping their affair can resume despite this, Jim is anxious to see him again.

The resolution of their relationship comes again in New York, where they end up on the bed in Bob's hotel room. But when Jim finally thinks he has attained what he wants and moves closer, Bob panics, is outraged to be thought of as gay, and even beats Jim. The two struggle, and Jim is infuriated enough to murder / rape (first edition / revised edition) Bob, realizing that Bob is basically just as homophobic as everyone else from his hometown.