In 1948 Mr. Vidal published “The City and the Pillar,” which was dedicated to J. T. (Jimmie Trimble). It is what would now be called a coming-out story, about a handsome, athletic young Virginia man who gradually discovers that he is homosexual. By today’s standards it is tame and discreet, but at the time it caused a scandal and was denounced as corrupt and pornographic. Mr. Vidal later claimed that the literary and critical establishment, The New York Times especially, had blacklisted him because of the book, and he may have been right. He had such trouble getting subsequent novels reviewed that he turned to writing mysteries under the pseudonym Edgar Box and then, for a time, gave up novel-writing altogether. To make a living he concentrated on writing for television, then for the stage and the movies.

Politics Onstage, and for Real

Work was plentiful. He wrote for most of the shows that presented hourlong original dramas in the 1950s, including “Studio One,” “Philco Television Playhouse” and “Goodyear Playhouse.” He became so adept, he could knock off an adaptation in a weekend and an original play in a week or two. He turned “Visit to a Small Planet,” his 1955 television drama about an alien who comes to earth to study the art of war, into a Broadway play. His most successful play was “The Best Man,” about two contenders for the presidential nomination. It ran for 520 performances on Broadway before it, too, became a well-received film, in 1964, with a cast headed by Henry Fonda and a screenplay by Mr. Vidal. It was revived on Broadway in 2000 and is now being revived there again as “Gore Vidal’s The Best Man.”

Mr. Vidal’s reputation as a script doctor was such that in 1956 MGM hired him as a contract writer; among other projects he helped rewrite the screenplay of “Ben-Hur,” though he was denied an official credit. He also wrote the screenplay for the movie adaptation of his friend Tennessee Williams’s play “Suddenly, Last Summer.”

By the end of the ’50s, though, Mr. Vidal, at last financially secure, had wearied of Hollywood and turned to politics. He had purchased Edgewater, a Greek Revival mansion in Dutchess County, N.Y., and it became his headquarters for his 1960 run for Congress. He was encouraged by Eleanor Roosevelt, a neighbor who had become a friend and adviser.

The 29th Congressional District was a Republican stronghold, and though Mr. Vidal, running as Eugene Gore on a platform that included taxing the wealthy, lost, he received more votes in running for the seat than any Democrat in 50 years. And he never tired of pointing out he did better in the district than the Democratic presidential candidate that year, John F. Kennedy.

Mr. Vidal also returned to writing novels in the ’60s and published three books in fairly quick succession: “Julian” (1964), “Washington, D.C.” (1967) and “Myra Breckinridge” (1968). “Julian,” which some critics still consider Mr. Vidal’s best, was a painstakingly researched historical novel about the fourth-century Roman emperor who tried to convert Christians back to paganism. (Mr. Vidal himself never had much use for religion, Christianity especially, which he once called “intrinsically funny.”) “Washington, D.C.” was a political novel set in the 1940s. “Myra Breckinridge,” Mr. Vidal’s own favorite among his books, was a campy black comedy about a male homosexual who has sexual reassignment surgery. (A 1970 film version, with Raquel Welch and Mae West, proved to be a disaster.)

Perhaps without intending it, Mr. Vidal had set a pattern. In the years to come he found his greatest successes with historical novels, notably what became known as his American Chronicles: “Washington, D.C.,” “Burr” (1973), “1876” (1976), “Lincoln” (1984), “Empire” (1987),“Hollywood” (1990) and “The Golden Age” (2000).