In a speech in Switzerland in 2011, then-Secretary of State Hillary Clinton made an unusually strong statement in defense of gay rights, saying they are equal to women's rights and racial equality and should be universal human rights. (Anja Niedringhaus/AP)

Three years into Hillary Clinton’s tenure as secretary of state, her chief of staff passed along a copy of an article sharply critical of President Obama for being too cautious in his embrace of same-sex marriage.

“Until now, the president’s position has been based on political expediency,” lawyer and gay rights advocate Richard Socarides wrote of Obama in the New Yorker in late 2011. “He has tried to have it both ways.”

The email was typical for Clinton, who read or sent a striking number of messages focused on the issue of gay marriage during her time as secretary of state, according to a trove of Clinton messages released by the State Department in recent months. The issue had little or no connection to Clinton’s diplomatic role at the time — but would be of keen interest to a once and future Democratic presidential candidate.

The pattern of the email traffic, and interviews with some of her correspondents from that time, strongly suggests that she had already made up her mind to support same-sex marriage after opposing it as a 2008 candidate. The emails also indicate the issue was a matter of some frustration — and perhaps lingering political competition — with Obama, who remained publicly opposed to gay marriage at the time.

“It was in the news, and I knew that she was interested in this and had been” for many years, Socarides recalled in an interview, noting that Hillary Clinton had attended gay rights briefings he led for White House staff when he worked for Bill Clinton.

“Of course I also knew that if she did decide to run for president this would be an issue for her to address,” Socarides said.

Now as a candidate, Clinton has reaped the benefits of her long ties with gay rights groups by receiving a rare primary endorsement from the Human Rights Campaign, the nation’s largest gay rights organization. The endorsement, which she formally accepted Sunday in Iowa, culminates a long wooing and lobbying relationship on both sides, the emails show.

Between the time of Clinton’s 2008 primary contest with Obama and his inauguration, a shift in the legal landscape and public opinion surrounding gay marriage was already underway. Once considered a far-fetched idea, full marriage rights became a rallying point for gay rights advocates that reached its peak during Obama’s first term. The issue was a political tightrope for many Democrats, Obama and Clinton included, as it moved through state legislatures and state and federal courts.

Clinton endorsed same-sex marriage in 2013, a few weeks after she left the State Department, in a video produced by the Human Rights Campaign.

On the campaign trail, Clinton frequently highlights actions she took on behalf of gay diplomats and their partners, as well as a landmark 2011 speech in which she declared that“gay rights are human rights” and pledged to make other nations’ treatment of gay people a factor in U.S. engagement.

Clinton was also keeping tabs on the state-by-state legal battles over marriage throughout her tenure, as evidenced by the regular stream of articles and commentary forwarded her way.

As a Cabinet official, Clinton was duty-bound not to get ahead of the Democrat who had defeated her for the 2008 nomination. Obama did not fully endorse same-sex marriage until May 2012, six months before he stood for reelection.

Catch up on the controversy and read the emails

But in the years before that, Clinton’s aides regularly sent along news articles and commentary — some of it withering — about what prominent gay rights activists saw as Obama’s slow pace on their agenda.

“I knew and respected the fact that she was a member of the Cabinet and had a number of constraints that prevented her from speaking out personally while her boss had not spoken out yet,” Socarides said.

Clinton took her own stop-and-start path toward full support for same-sex marriage, generally shifting her position as public opinion changed. She had, at times, said she defined marriage as a union solely between men and women, supported civil unions as an alternative to legal marriage, and embraced gay unions as a crowning achievement of human and civil rights.

In many cases, activists and Clinton political allies from years past sent material to Clinton chief of staff Cheryl Mills with hopes it would then be given to Clinton. What is not clear from the emails is whether Clinton also discussed the same issues widely or solicited any of the communication by means other than email.

Socarides sent a few of his New Yorker pieces to Mills, including the December 2011 piece in which he correctly predicted both Obama’s pre-2012-election statement of support for marriage equality and the eventual legal victory for same-sex marriage.

The same week that piece appeared, Sen. Robert Menendez (D-N.J.)had announced his shift in favor of same-sex marriage in an op-ed published in the Newark Star-Ledger. Mills sent the piece to Clinton after getting a copy from Winnie Stachelberg, a senior official at the liberal advocacy group Center for American Progress, then headed by longtime Clinton insider John Podesta. Podesta now chairs Clinton’s campaign.

In 2011, Stachelberg had sent along CAP’s statement on the announcement that Obama would support legislation to repeal the Defense of Marriage Act. In 2012, she sought to tip off Clinton’s office about a forthcoming Obama interview in which he would declare his support for same-sex marriage.

In January 2013, as Obama prepared to begin his second term, longtime Clinton friend Burns Strider passed along an article about essayist Wendell Berry’s support for same-sex marriage. Strider tells Clinton he has also sent the article to “Jon and the gang,” presumably meaning White House speechwriter Jon Favreau.

Clinton’s political interest in gay and lesbian issues is evident almost from the start of her tenure at the State Department. In June 2009, Clinton aide Nora Toiv sent Mills and two other senior aides, foreign policy adviser Jake Sullivan and image adviser Philippe Reines, a Politico article headlined, “Gay Groups Grow Impatient with Obama.”

The article, which Mills sent on to Clinton, outlined frustration with the pace of Obama’s gay rights agenda. Obama had not yet fulfilled a promise to repeal the Defense of Marriage Act or the Pentagon’s ban on openly gay military service, the story noted. The piece quoted gay activists, pollsters and politicians as saying Obama was behind the times for Democrats politically by failing to endorse same-sex marriage and had angered gay groups by appearing to joke about the issue.

In February 2012, the emails show that Clinton was asked to help lobby a Democratic delegate in Maryland, Sam Arora, who was wavering on whether to vote in favor of same-sex marriage. Georgetown University law professor and Clinton friend Peter Edelman appealed to Mills for Clinton’s help.

“The people who are working the gay marriage bill in the Maryland legislature think it would be helpful if someone could find an appropriate way to let Mr. Arora know on Hillary’s behalf that it would be great if he could vote for the bill,” Edelman wrote.

There is no indication that Clinton became directly engaged in the matter, and Edelman said in an interview that he did not have “any sense of her overall thinking” when he reached out.

“Please let him know Bill called — unsuccessfully,” Clinton wrote to Mills, presumably referring to her husband.

In any event, the push didn’t work: Arora ended up voting no.