Frank Sharry is the founder and executive director of America’s Voice.

There is something about being under attack that makes a movement stronger.

I’ve been an advocate for immigrants for 30 years, working with Central Americans in Boston and policymakers in Washington. And for a long time, my colleagues and I assumed that if we developed strong reform ideas and clever lobbying strategies, we’d help create a road map to citizenship for the 11 million undocumented immigrants living and working in America.

But in 2005, with the rise of the Minutemen and fresh attention from Capitol Hill, many in the Republican Party started to turn immigration into a wedge issue. They demonized hardworking immigrants as criminals and moochers. They blocked national reform and passed harsh state laws aimed at purging immigrants. Their goal: to make life so miserable for undocumented immigrants that they would be forced to leave the country. Democrats were divided, our opponents were on the march, and we in the immigrants’ rights movement were on the defensive. Fortunately, we had a community we could learn from, look up to, emulate. And that was the LGBT movement.

The lesbian, gay, bisexual and transgender community might have been even more marginalized than ours. In fact, I used to joke with a friend who works for an LGBT activist group about who was lower on the totem pole, gays or immigrants. But the LGBT movement bounced back from significant setbacks a decade ago to win multiple state referenda on marriage equality, turn the Obama administration around on the federal Defense of Marriage Act and repeal “don’t ask, don’t tell.”

(Brian Stauffer for The Washington Post)

This coming week, the Supreme Court will hear arguments in challenges to California’s Proposition 8, which restricts marriage to opposite-sex couples, and to DOMA, which prohibits the federal government from recognizing same-sex marriages performed in places where they are legal. The historic cases could produce a huge victory for the LGBT community and its quest for marriage equality.

We’re making progress, too. Next month, a bipartisan Gang of Eight in the Senate is expected to introduce a proposal that we think will lead Congress to approve a strong immigration reform package this year — a triumph for immigrant workers and families who want a shot at citizenship.

To get to this point, we learned three crucial lessons from LGBT activists: We had to build a movement. We couldn’t be afraid to challenge our friends in power. And we had to give our cause a human face.

LGBT advocates showed us that the way to build power is by leveraging your competitive advantage. If money and votes are the currency of politics, their strength was in the former. Snarkily referred to by donors and beneficiaries alike as the “Gay ATM,” LGBT contributors gave generously to political candidates and won themselves a seat at the table.

Our strength lies in the other form of political currency: voters. After the devastating defeat of the McCain-Kennedy immigration reform bill in 2007, we made it our top priority to mobilize new Latino voters, who see immigration reform as a defining issue. Labor unions such as the SEIU and Unite Here and community organizations such as the Center for Community Change and the National Council of La Raza built a robust infrastructure of voter-registration and get-out-the-vote operations in key states.

In 2008, Latino and immigrant voters were part of the coalition that helped elect Barack Obama and many other Democrats. In 2010, Latino voters helped Democrats hold their majority in the Senate by supporting Harry Reid, Michael Bennet and others in close races. And in 2012, Latino and Asian voters joined with African American, female, LGBT and young voters to help spell the difference in the contests for the White House and the Senate.

The numbers are striking. In 2004, 7.6 million Hispanics voted, making up 6 percent of the electorate. By 2012, they had grown to 10 percent of the vote.

Last year’s turnout showed Democrats that, instead of running away from immigration reform, they had to deliver. And many Republicans realized that they needed to get some credit for helping to pass immigration reform to regain their competitiveness with Latino voters.

We learned something else from the LGBT community. Early in Obama’s first term, when most progressives were swooning about the new president and the new era his election had ushered in, LGBT activists had a different take. Dismissing the Washington-insider notion that access means influence, they made it clear that they were not going to go along to get along. Led by bloggers such as John Aravosis, Joe Sudbay and Pam Spaulding, the LGBT community developed an outside strategy that openly challenged the White House.

Their first battle was over the president’s defense of DOMA. They were confrontational and fearless. LGBT advocates then upped the pressure on the White House and Congress to move on the repeal of “don’t ask, don’t tell.” Unwilling to accept the line that “we’d like to help you, but those Republicans just won’t let us,” gay activists mobilized donors, got arrested at the White House, demanded action and ultimately succeeded in repealing the military policy.

On immigration, most of Obama’s first term offered encouraging reform rhetoric, but not a lot of progress on policy. While the speeches were inspiring and the early meetings friendly, advocates like me had to face facts: We weren’t getting anywhere. In fact, the Department of Homeland Security was ramping up deportations to record levels. We strongly suspected that then-White House Chief of Staff Rahm Emanuel, who had famously called immigration a third-rail issue for Democrats in 2007, was saying much the same to the president.

And so, again, we applied a lesson from the LGBT activists. We even came up with a new rallying cry: “It’s time to go all LGBT on their a--.” I used it around the office and in meetings with colleagues. I meant, quite simply, that it was time to be confrontational.

Our movement demanded that the administration stop deporting the young undocumented immigrants who call themselves “Dreamers.” We demanded that the Department of Homeland Security follow the president’s stated priorities and target serious criminals for deportation, not moms and dads picked up for driving with broken taillights. We insisted that officials find a way to keep families together rather than continue policies that had deprived an estimated 100,000 children of a parent because of deportation. Activists held rallies, signed petitions, lobbied officials, organized to stop individual deportations and got arrested in acts of civil disobedience.

One of the turning points came in July 2011, when Obama spoke to the annual conference of the National Council of La Raza. He was trying to explain that Congress makes the laws and the executive branch enforces them, so he couldn’t just change immigration policies unilaterally. Interrupting his speech, a group of Dreamers stood up and started chanting, “Yes, you can!” Soon the entire audience joined in. The president remained cool, but the movement had turned an Obama campaign slogan into a strong challenge. I remember thinking that the president’s explanations were falling flat and that he would have to make some big changes. If not, he risked a very depressed Latino turnout in 2012.

The final lesson our movement learned from the LGBT community may have been the most important. Gays and lesbians have created a monumental shift in American culture. They did it, first and foremost, by coming out to family and friends. They did it by infusing popular culture with popular characters, from Ellen to Will to Mitch and Cam. They did it by being brave and loud, out and proud.

We had nothing of the sort. To most Americans, undocumented immigrants were unknown and invisible. To some, they represented a menace. But then, just a few years ago, Dreamers — who take their name from the Dream Act, which would create a path to citizenship for young people who go to college or serve in the military — started to come out as “undocumented and unafraid.” They risked arrest, detention and deportation to fight for their freedom, their futures and their families. They became the heart of the movement, and their courage opened millions of minds. In 2010, four brave Dreamers walked 1,500 miles from Miami to Washington. In 2011, Pulitzer Prize-winning journalist Jose Antonio Vargascame out as an undocumented immigrant in the New York Times Magazine.

Suddenly, the human faces and personal stories so sorely missing in our debate broke through as never before.

In response to the rising pressure, the president and his team began taking steps to humanize the harsh immigration enforcement system. But the Department of Homeland Security kept undermining the White House, implementing those policy changes in the most restrictive way possible.

Many advocates despaired. It was now dangerously close to the 2012 election, and the last thing immigrant advocates wanted to do was to criticize the president in a way that would depress the Latino vote and help Mitt Romney, the most anti-immigrant presidential nominee in a generation, win the White House.

But the Dreamers pressed on. Much as same-sex-marriage advocates kept pushing Obama to “evolve” and support marriage equality, the Dreamers wanted relief and were not going to wait until after the election to get it. On May 9, 2012, the president announced his support for same-sex marriage. On June 15, 2012, he announced a new policy that granted work permits and relief from deportation for hundreds of thousands of Dreamers.

The two decisions not only generated celebrations and intense enthusiasm in our movements, but they rallied progressives, found favor with swing voters and threw Romney and the Republicans on the defensive. The fear of conservative blowback and the ghost of Rahm were both slayed.

The president’s decisions — and the movements that pushed him to make them — helped him win reelection. Latino voters showed up in record numbers and produced a mandate that is motivating both parties to reach for a breakthrough.

Today, polls show strong support for marriage equality and for a path to citizenship for undocumented immigrants. Conservative hero Ted Olson will argue for LGBT equality at the Supreme Court, and rising Republican stars such as Rand Paul are arguing for immigration reform. What a difference a few years — and a couple of movements — can make.

So, to my LGBT brothers and sisters, I say, good luck this coming week. Thank you for the inspiration. You showed the way: Build a movement. Capitalize on your strengths. Touch hearts and minds. Be tough. And remember, no matter how bleak it gets, don’t get down, get strong.

Read more from Outlook, friend us on Facebook, and follow us on Twitter.