The Washington Post’s Ed O’Keefe talks with retiring Rep. Barney Frank (D-Mass.) about how he opened up to his House colleagues about his sexuality before he came out of the closet. (The Washington Post)

The story of how Barney Frank became the nation’s first openly gay member of Congress pretty much begins with a double date on New Year’s Eve in Egypt in 1982.

Frank traveled with Sen. Thomas R. Carper (D-Del.), who was then a House colleague and not yet married. Carper had met two female flight attendants on the trip to Egypt and set up a double date with Frank.

“It was clear that I was not nearly as interested as he was,” Frank said. “So he asked me the next morning whether, why I was not more forthcoming with the friend, and I told him.”

He was gay, but not ready to be openly so.

Frank (D-Mass.), who is retiring after more than three decades in Congress, is easily the nation’s most prominent gay politician and one who charted a path for others like him.

“I certainly regard Barney Frank as somebody who is an incredible role model in my life and who showed me and so many others that this could be achieved,” said Rep. Tammy Baldwin (D-Wis.), who in November became the first openly gay candidate elected to the Senate.

Frank will be remembered as a champion of financial regulatory reforms enacted in the wake of the 2008 economic collapse. As chairman of the House Financial Services Committee, he led the effort to rein in Wall Street, and the Dodd-Frank legislation that bears his name represented some of the most significant changes to financial regulation since those that followed the Great Depression.

The low point of his career came in July 1990, when the House voted 408 to 18 to reprimand him for using his position to fix tickets for a male prostitute with whom he had been sexually involved.

Frank survived the humiliation and became a liberal darling who worked to limit the use of the death penalty and federal drug laws. He helped thwart Republican efforts to impeach President Bill Clinton and worked with the George W. Bush administration to pass the Troubled Assets Relief Program. Along the way, he has been a popular television figure, often appearing to spar with show hosts or guests presenting a contrarian view.

Frank’s retirement is occurring at an important moment in the gay rights movement. It was just two years ago that the Pentagon repealed its ban on gay men and lesbians serving openly in uniform. And his departure comes as federal courts are considering challenges to the nation’s ban on same-sex marriage. He also is leaving a Congress that is much more welcoming to gays than the one he entered 32 years ago. The 113th Congress, which will convene in January, will include seven openly gay or bisexual members, a record number.

Frank did not publicly disclose that he was gay until 1987, but in a recent interview he described how he wrestled with the question during his first run for Congress, in 1980, and in the years following.

“When I decided to run, I said, ‘Either you come out and become an activist and have a major role there, or I run for Congress,’ ” Frank said. “There was no way I could have been out and won.” In fact, he said, rumors that he was gay nearly cost him that first election. “In the end, I almost lost on suspicion,” he said.

Carper was not the first member of Congress to whom Frank acknowledged that he was gay.

Once, in a casual conversation, the late Rep. Mike Synar (D-Okla.) asked Frank whether he had a girlfriend.

“No,” Frank replied.

“Are you gay?” Synar asked.

“Well, yeah,” Frank said.

There was no further discussion.

Then came the trip to Egypt with Carper.

Carper recalled the New Year’s Eve double date and said he noticed that Frank didn’t kiss his date when the clock struck midnight. The next morning, he felt compelled to ask about the lack of interest in the woman. Frank told him he would have rather dated the woman’s brother.

“I was pretty nonchalant about it,” Carper said. “And Barney told me later that it was one of the conversations that gave him the courage for him to tell others. It was a funny moment, but it was an important moment for him, and maybe for the rest of us.”

Four years after telling Carper, Frank told his mentor, House Speaker Thomas P. “Tip” O’Neill (D-Mass.), because former ­congressman Robert Bauman (R-Md.) was on the verge of publishing a book that suggested that Frank was gay. Concerned that the book might cause a stir, Frank went to see O’Neill, who initially dismissed the news as a rumor.

“But I said, ‘Well, in this case it’s true,’ ” Frank recalled, adding that O’Neill responded with some sadness and told him, “I thought you might be the first Jewish speaker.”

O’Neill then alerted his press secretary — future talk show host Chris Matthews — that Frank soon “may be coming out of the room.” Aides had to explain that the meta­phor was that Frank was coming out of the closet.

Although he does enjoy some stature as a trailblazer, Frank has been a politically polarizing figure, even in the gay political community. Richard Tisei, a Massachusetts Republican who is gay and lost his bid for a House seat this year, faced harsh political attacks from Frank during his campaign. He credited the congressman with advancing gay rights but said in an e-mail that “in recent times his caustic demeanor and hyperpartisanship limited his ability to reach out to a broader audience to help change opinions and build consensus.” He added: “To be successful in the future we need different types of leaders who aren’t so polarizing and who are able to build bridges and promote better understanding of the issues affecting the LGBT [lesbian, gay, bisexual and transgender] community.”

In July, Frank married his longtime partner, James Ready, and introduced him on the Hill as his husband. But Frank’s professional life has emphasized his role as a lawmaker who is gay, rather than as a gay activist who is a member of Congress.

He said that although he has counseled a few state legislators about coming out, he has not played that role for any other members of Congress. His advice has been that people should come out when they are ready.

“Do it if you feel that strongly, forgetting about the political consequences,” Frank said. “Once you do, then your job is once you’re out, if there are people who are deeply prejudiced against you because of who you are, forget them — you can’t waste your time on them.”

Frank moved out of his suite in the Rayburn House Office Building last week and is biding his time in a tiny office off the Cannon House Office Building rotunda. He said his only regrets are not voting for the 1991 Persian Gulf War (“I thought George Bush Sr. handled that one well”) and not sensing the beginnings of the nation’s housing crisis more quickly. But he said President Obama’s reelection affirms the financial regulatory reforms he helped enact in recent years and makes it easier for him to leave now, despite any other unfinished business.

“I’m worn out. I’m 72, I’ll be 73 in a couple of months,” he said. “I had never thought I’d stay after 75.”