Jim Graham, an unflagging leader of Washington’s largest gay men’s clinic during the AIDS epidemic who served 16 years on the D.C. Council before a corruption scandal upended his quest for a fifth term in 2014, died June 11 at a hospital in Washington. He was 71.

Mr. Graham was battling a bacterial infection and died of a “chronic obstructive pulmonary disorder,” said his partner, Christopher Watkins.

A Democrat known for his tortoiseshell glasses, florid bow ties and crisp suits, Mr. Graham could be a pugnacious advocate for causes and constituents. He helped bring in a Target store and other real estate projects that remade two major corridors slicing through his Ward 1 District — U Street NW and 14th Street NW, both of which had been battered during the 1968 riots after the assassination of the Rev. Martin Luther King Jr.

Yet even as he celebrated the growing affluence in his ward, a swath that included Adams Morgan and Columbia Heights, Mr. Graham sought to protect affordable housing and used his council perch to investigate developers accused of violating tenants’ rights.

“Jim Graham embodied D.C. values,” Mayor Muriel E. Bowser (D) said in a statement that described him as a “fierce champion” for his constituents.

A law school graduate who once worked as a clerk for Chief Justice Earl Warren, Mr. Graham gained prominence in the 1980s as an aggressive advocate for gay residents, serving as the director of the Whitman-Walker Clinic during the AIDS crisis.

When he joined the council in 1998, Mr. Graham became the body’s second openly gay member — the first had been Republican David Catania, in 1997 — and his election helped to crystallize the growing influence of the city’s gay community.

“Jim represented, as David did, a seat at the table for the gay community,” said Rick Rosendall, the former president of the Gay and Lesbian Activists Alliance. “He was sort of an institution here.”

At the wheel of his cream-colored Volkswagen convertible, the top often down, Mr. Graham understood that voters like to know their politicians, and he was forthright about his past struggles with alcoholism and about his early marriage to a woman, Patty Wilson, a union that fell apart as he came to terms with his homosexuality.

A ubiquitous presence in his ward, Mr. Graham showed up at block parties, ribbon cuttings and civic meetings, no matter the crowd’s size. If macro issues were his focus at city hall, he understood that it was often small gestures that captured voters’s loyalty. He won over many of his constituents with his rapid response to their demands for everything from new garbage cans to pothole repairs, his flurry of emails always signed, “Bests, Jim.”

“He was very astute and well versed in the minutia of government,” said Bryan Weaver, an Adams Morgan activist who unsuccessfully opposed Mr. Graham for reelection in 2010. “He actually cared about the invisible communities — immigrants, returning citizens, seniors. He reached out to people in a lot of ways.”

Mr. Graham remained popular with voters even as he faced mounting criticism that he was too closely aligned with real estate developers and too often pushed council colleagues to support generous abatements for developers’ projects.

Yet by 2014, Mr. Graham found himself tarnished by corruption scandals. Ted Loza, his chief of staff, had pleaded guilty to accepting a bribe. And Mr. Graham himself was accused of seeking to steer a Metro project to a political contributor, a charge that resulted in a council reprimand.

Brianne K. Nadeau, a little-known candidate who opposed Mr. Graham in 2014, portrayed him in a blizzard of mailings as an ethically challenged incumbent who had overstayed his welcome. Her pitch infuriated Mr. Graham, even as he conceded that his purported foibles were fair political game.

“She ran around calling me a crooked politician,” he told The Washington Post at the time. “I don’t blame her — she used the ammunition she was given.”

James McMillan Nielson Graham was born in Wishaw, Scotland, on Aug. 26, 1945. In search of better opportunities in the postwar drear of Great Britain, his parents settled in Michigan and his father worked in the automobile industry.

Jim Graham was a 1967 political science graduate of Michigan State University, where he had been president of the student body. He had inherited his parents’s hard-line conservatism — they were Goldwater Republicans — but he once told The Post that he had a political epiphany when he joined a group of student body leaders in Washington for a special audience with Secretary of State Dean Rusk.

What would happen if the bombing of North Vietnam were not to succeed, Mr. Graham asked the hawkish Rusk.

“Somebody’s going to get hurt,” he recalled Rusk replying

Mr. Graham said he was appalled, triggering a commitment to student activism against the war. “It was obvious to anyone who was listening that the United States was planning to forcibly bring the Vietnamese people to their knees at whatever cost,” he told The Post. He wore his hair in a ponytail and contemplated returning to Scotland and was relieved when he got a higher draft number.

After graduating from the University of Michigan law school in 1971, he clerked for Warren, who hired him to help him write his memoirs. The chief justice died before the project began, and Mr. Graham went to Capitol Hill, working for Senate subcommittees and a federal agency that managed multi-employer pension plans. “I sat in meetings with actuaries,” Mr. Graham told The Post in 2006. “It wasn’t too long before I realized this was death.”

As the AIDS epidemic unfolded, Mr. Graham gravitated to the Whitman-Walker Clinic, which became the largest health-care provider for HIV patients in the D.C. area. He started volunteering in 1979 and joined the board before becoming the clinic’s executive director in 1984, building a reputation as a shrewd financial manager at a time when the city government was defined by financial mismanagement.

“I never missed a payroll,” he once said. “And although we had a line of credit, I never used it.”

Launching his first campaign for the council in 1998, he beat incumbent Frank Smith, an African American man who had been a civil rights activist, and began a stint that ended 16 years later when Nadeau defeated him.

Mr. Graham may have been finished with politics, but he wasn’t done with the limelight. A year after his defeat, he announced that he was promoting all-male strip shows at a club called The House, inviting camera crews to film his new enterprise on Georgia Avenue NW.

“I wanted it to be fun,” the former councilman told a reporter, explaining his career turn. “And I wanted to make some money.”

CORRECTION: The obituary incorrectly described Mr. Graham’s status for the draft during the Vietnam War. He was relieved to have had a higher draft number, not a lower draft number. The story has been revised.