Willie Garson, a versatile character actor who played con men, criminals and charming sidekicks, including Carrie Bradshaw’s sharply dressed confidant Stanford Blatch — the gay talent agent who always had a pithy comment — in the HBO series “Sex and the City,” died Sept. 21 in Los Angeles. He was 57.

His manager Gladys Gonzalez confirmed the death but did not give a cause.

The bald and bespectacled Mr. Garson appeared in 170 movies and TV shows, starring as the con artist Mozzie in the USA police procedural “White Collar” (2009-2014) and as a New Jersey transplant with a criminal past in “Hawaii 5-0” (2015-2020), a CBS reboot of the classic action series.

But he remained best known for playing Stanford, Carrie’s gossip-loving friend in “Sex and the City,” a character he said he based on one of his former agents. The show premiered in 1998 and ran for six seasons, examining the careers, friendships and sex lives of four women in New York City while becoming one of HBO’s first hit original series.

Mr. Garson was far from the show’s star — that would be Sarah Jessica Parker, as the sex columnist Carrie, along with Kim Cattrall, Kristin Davis and Cynthia Nixon, who played her three best friends. But beginning with the show’s second episode, he stole scenes with his wry delivery (“Oh, my God, she’s fashion roadkill”) and commentary on gay life.

“We all judge. That’s our hobby,” he observed in one episode. “Some people do arts and crafts. We judge.”

Mr. Garson, who was not gay, told HuffPost U.K. in 2016 that he felt pressure not to deliver an offensive portrayal of a gay man, and was so nervous about his performance that he didn’t subscribe to HBO for the show’s first three seasons. “But the gay community really rose up,” he recalled, “and said, ‘We know people like this, this is real,’ ” leading him to start watching the series.

He later reprised the role for a 2008 “Sex and the City” movie and a 2010 sequel, in which his character marries the event planner Anthony (Mario Cantone) in a ceremony officiated by Liza Minnelli. In recent months, he was working on a sequel series, “And Just Like That . . . ,” which is slated to reunite most of the original cast.

“His spirit and his dedication to his craft was present every day filming ‘And Just Like That,’ ” executive producer Michael Patrick King said in a statement. “He was there — giving us his all — even while he was sick.”

William Garson Paszamant was born in Highland Park, N.J., on Feb. 20, 1964. He shared few details about his upbringing, but said his father ran a business providing televisions for hospital patients. “It was a little ‘Soprano’-like,” he told one interviewer, referring to the HBO mob series. “I really can’t go further into it.”

Mr. Garson studied at the Actors Institute in New York as a teenager and graduated from Wesleyan University in 1985 with a bachelor’s degree in psychology and theater. A year later, he made his on-screen debut, appearing in the TV miniseries “The Deliberate Stranger” and in episodes of “Family Ties” and “Cheers.”

He went on to make guest appearances on shows including “Ally McBeal,” “Twin Peaks” and the sitcoms “It’s a Living,” “Mr. Belvedere” and “Ask Harriet.” On a whim, he also auditioned to play Lee Harvey Oswald in Oliver Stone’s 1991 movie “JFK.” The part went to Gary Oldman, but word got around that Mr. Garson had an uncanny resemblance to President John F. Kennedy’s assassin.

“I went in for ‘Ruby,’ and they were dying to have me — a wonderful feeling for an actor,” he told the magazine Portland Monthly, referring to the 1992 movie about Oswald’s killer, Jack Ruby. “The executive producer told me he’d been in Korea with Lee Harvey Oswald [and that] I was the definitive Oswald. So I did it.” He played Oswald twice more, on “Mad TV” and the time-travel series “Quantum Leap.”

In the 1990s and 2000s, Mr. Garson had small roles in a host of popular TV shows — “Friends,” “The X-Files,” “Stargate SG-1,” “Boy Meets World” — and in movies including “The Rock,” “There’s Something About Mary,” “Being John Malkovich” and “Groundhog Day,” in which he played the assistant to Bill Murray’s cynical TV weatherman. He also had a recurring role in “NYPD Blue” as Henry Coffield, a neighbor of Jimmy Smits’s detective character, and recently played Lex Luthor’s cellmate on the CW series “Supergirl.”

“If you’re a leading-man kind of guy, you get two parts and they immediately put you to carry movies,” he said in a 2000 interview with Knight Ridder newspapers. “That’s really scary to me the way they do that to people. A great character actor’s career should be 50 years. I don’t want five years of unlimited money, unlimited da-da-da. I want to work for the rest of my life.”

Mr. Garson was also a talented poker player who earned the nickname Evil Willie after beating players including Ben Affleck in Bravo’s “Celebrity Poker Showdown.” “I was in Ohio doing some work on John Kerry’s campaign, on a bus with a bunch of other actors, and almost every time we got off the bus, the first person fans would come over to talk to would be me — about poker,” he told Vanity Fair in 2005. “But maybe that’s just the heartland for you. Not a lot of people watching ‘Sex and the City’ there.”

Complete information on survivors was not immediately available, but Mr. Garson had a son, Nathen, whom he adopted from foster care in 2010. He volunteered for adoption advocacy groups including Second Nurture, the Alliance for Children’s Rights and You Gotta Believe, and often spoke of undergoing a transformation after becoming a father.

“I’m a narcissistic, entitled, spoiled actor. So my entire life has been focused on myself — until the moment I met Nathen,” he told People magazine’s streaming network last year. “And then it wasn’t. And it’s a better life.”