On Aug. 6, the top 10 Republican contenders for their party’s presidential nomination—as measured by the average of five national polls—will take the stage in Cleveland for the first of a scheduled 11 primary debates over the next eight months. The candidates will take turns attacking the Affordable Care Act, denouncing President Barack Obama’s Iran deal and insisting on the need to promote economic growth by cutting taxes, curbing regulation and reducing spending.

But as inviting a target as the president and his policies present, the GOP hopefuls may well save their sharpest attacks for one another. Recent weeks have highlighted both prominent fissures among conservatives and the challenges posed to their movement by the country’s changing social and political terrain.

In a rambling announcement of his candidacy in mid-June, Donald Trump declared that Mexico is “sending” criminals, including “rapists,” to the U.S. Former Gov. Jeb Bush and Sen. Marco Rubio criticized his inflammatory opinions, but Mr. Trump only doubled down on his immigration stance.

A week later, Republican Gov. Nikki Haley of South Carolina—responding to the racially motivated massacre of nine African-Americans at a Charleston church—called for the removal of the Confederate battle flag from the State House grounds. Sens. Lindsey Graham and Tim Scott, also Republicans, stood by her side. Ms. Haley, a two-term governor and rising GOP star, offended traditionalists throughout the South and raised the hackles of many conservatives elsewhere who balk at even the appearance of kowtowing to political correctness. But within two weeks, South Carolina’s Republican-dominated House and Senate voted overwhelmingly to remove the Confederate flag from the State House grounds. It came down July 10.

Three days after Ms. Haley’s statement, in a 6-3 majority opinion by Chief Justice John Roberts, the Supreme Court upheld the Internal Revenue Service’s interpretation of an obscure but crucial provision of the Affordable Care Act. To the consternation of conservatives—not least Justice Antonin Scalia, who wrote a scorching dissent, and Justices Clarence Thomas and Samuel Alito, who joined it—this was the second time in three years that Justice Roberts had provided a justification for rejecting a legal challenge that could well have doomed President Obama’s signature domestic legislation.

The next day, in a 5-4 majority opinion written by Justice Anthony Kennedy, the Supreme Court discovered in the due-process and equal-protection clauses of the 14th Amendment a fundamental right to same-sex marriage. Justices Roberts, Scalia, Thomas and Alito each penned strongly worded dissents, contending that the majority’s holding had no basis in law, arrogated power to the judiciary and encouraged the pernicious notion that opposition to same-sex marriage could only arise from—and express—ignorance or bigotry.

It has been, in short, a rough month for conservatives. But it’s nothing that conservatives who draw on the best in their own tradition can’t handle.

The conservative movement in the U.S. arose in the years after World War II, in response to the New Deal’s enormous enlargement of the welfare state and the Cold War-era threat of expansionist totalitarian communism. Since those days, conservatives have successfully managed a range of setbacks and challenges, and they can do so again today.

They should forthrightly reaffirm their commitment to the Constitution’s principles of individual freedom, equality under law, and limited government—all of which presuppose and protect religious faith and traditional morality. They should distinguish among what they can alter, what they must accept and what they should embrace. And they should design principled reforms that can win majority support in a country where diversity ensures that any conceivable national majority will include a significant spectrum of opinion.

Conservatives should also recall their shifting fortunes over the relatively short history of their movement, a history that underscores how much their political prospects depend on the capacity, favored by our constitutional system, to harmonize principle with the claims of democratic sentiment.

The movement’s first national standard-bearer was Sen. Barry Goldwater. In 1964, the Arizonan lost to President Lyndon Johnson in a landslide: Johnson carried 44 states and the District of Columbia, won 486 electoral votes to Goldwater’s 52 and took 61% of the popular vote. Conservatism seemed thoroughly repudiated.

Republicans prevailed in five of the next six presidential elections. In 1984, former Goldwater supporter Ronald Reagan won re-election in a landslide of his own, taking 525 electoral votes to Walter Mondale’s 13, carrying 49 states (leaving Mr. Mondale only his home state of Minnesota and the District of Columbia) and winning 59% of the popular vote.

The synthesis of individual liberty, limited government and respect for tradition and faith that Reagan embodied eroded in the 1990s under the brash leadership of House Speaker Newt Gingrich. It deteriorated further during the presidency of George W. Bush.

 

The Bush administration’s war on terror, invasion of Iraq and big domestic spending so divided conservatives that, as Mr. Bush left office in 2009, the two main camps in contemporary conservatism—social conservatives and limited-government or libertarian conservatives—wanted nothing more to do with each other.

It fell to Mr. Obama to reunite conservatives. He managed to do this within months of his inauguration—with a pork-laden $800 billion stimulus package and a determined push, despite a historic economic crisis, to enact comprehensive health-care reform. With these sweeping measures, Mr. Obama convinced quarreling conservatives that their shared opposition to his agenda outweighed their philosophical differences.

Energized by the tea-party movement—which includes many social conservatives committed to restoring limits on the federal government—conservatives came storming back in the 2010 midterm elections. By winning control of the House of Representatives, they created a major roadblock to the president’s ambitions.

Although Mr. Obama managed to secure a second term in 2012, Republicans enjoyed dramatic gains in the 2014 midterm elections: They extended their margin in the House, took the Senate and scored historic victories in state races, resulting in GOP control of 31 governorships and more than two-thirds of all state legislative chambers.

When viewed against the backdrop of conservatism’s vicissitudes over the last 65 years, this summer’s controversies seem considerably less than catastrophic.

To be sure, Mr. Trump’s demagoguery on immigration is a recipe for alienating the center right and independents, whose votes are indispensable to Republican hopes for winning the White House—to say nothing of the country’s fast-growing bloc of Latino voters, many of them clustered in highly contested states. But conservatives should acknowledge that Mr. Trump has tapped into widely shared anxieties.

To regain their footing on these issues, conservatives should support lawful immigration. This will require serious candidates to set out proposals to secure the nation’s borders, reform the immigration system, welcome properly admitted newcomers from around the world and deal humanely with the millions of undocumented immigrants who have been encouraged—by means of lax law enforcement and economic inducements—to enter the country illegally and remain here without documentation.

 

The removal of the Confederate battle flag from the South Carolina State House grounds also exposed tensions within conservatism, but it was no setback for conservatives. To the contrary, it was a sign of maturity. As Ms. Haley argued, though the flag may represent pride in their history and heritage for many Americans, for many of their fellow citizens, the flag is, quite understandably, “a deeply offensive symbol of a brutally oppressive past.”

It was entirely fitting for a conservative—and for South Carolina’s first female and first Indian-American governor—to lead in eliminating government endorsement of a symbol inextricably bound up with the Confederacy, a regime devoted to the preservation and extension of slavery and the dissolution of the union.

It was also entirely in keeping with conservatives’ devotion to free expression for Ms. Haley to emphasize that “those who wish to show their respect for the flag on their private property” remain free to do so. She resisted the noxious doctrine now flourishing on university campuses that any utterance or idea that offends any member of any protected or favored group must be silenced.

Beyond the flag controversy, the response of Charleston’s citizens to the hate-filled attack was itself a vindication of conservative confidence in American principles and virtues. The heroic coming together of the city’s leaders—black, white, Christian and Jewish—in the immediate aftermath of the mass murder attested to the wellsprings of community, compassion and moral courage in America. And the awe-inspiring expressions of forgiveness by family members of the victims demonstrated the power of religious faith to elevate our humanity.

As with the call to take down the Confederate flag, the Supreme Court’s June rejection of a challenge to the Affordable Care Act didn’t represent a fundamental threat to conservatism. Justice Roberts for the majority and Justice Scalia in dissent agree that the court must exercise restraint to perform its essentially nonpolitical role of adjudicating cases and controversies in accord with the law. They just disagreed in this instance about what that required. Justice Roberts suggested that restraint obliges the court to search assiduously for a reading of the text that leaves the resolution of big social and economic issues to the political branches, whereas Justice Scalia insisted on the imperative to hew to the original understanding of legal texts.

More to the point as a practical matter, the court’s ruling in King v. Burwell doesn’t mean that the Affordable Care Act is here to stay. The act continues to lack majority support in opinion polls. Though there has long been a consensus that the federal government has a vital role to play in providing affordable health care for all, a vital role isn’t necessarily a dominant role.

The coming debates provide Republican presidential candidates an opportunity to introduce thoughtful reforms—including the repeal and replacement of Obamacare—that provide maximum room for market forces to discipline the price and quality of health insurance and expand its availability.

The Supreme Court’s decision in the same-sex marriage case, which united the four most conservative justices, presents challenges of a different sort. Gay marriage was a fringe concern 25 years ago, but it has acquired majority support. Many young conservatives are comfortable with it, and the trend shows no signs of abating.

Even if the court hadn’t precipitously intervened, same-sex marriage probably would have continued steadily gaining acceptance throughout the country. Because of the moral, political and even conservative grounds in its favor, it is futile for conservatives to attempt to overturn the ruling on legal grounds, however much the court overreached in finding a fundamental right where none had been known to exist.

Among the most unfortunate consequences of Obergefell v. Hodges for conservatives—and for democratic debate—is that it encourages the view that opposition to changing the meaning of marriage to include same-sex couples is tantamount to the rejection of gay rights and reflects rank prejudice. Justice Kennedy’s majority opinion lends legitimacy to the pernicious tendency to denounce those who think differently as deniers, haters and extremists.

So those arguing that the traditional family is the best institution for raising children must not only reaffirm limited government in light of Obergefell’s expansion of federal power; they must also champion freedom of thought and discussion. They must remind their fellow citizens of the indispensability of dissent and divergent opinions. In so doing, they will uphold not only their own moral convictions but also major principles of the American tradition.

Conservatives must also prepare for battles that will pit the new, implicit constitutional right to same-sex marriage against the old, explicit constitutional right to the free exercise of religion. On July 2, less than a week after the court’s same-sex marriage decision, Oregon Labor Commissioner Brad Avakian ordered Aaron and Melissa Klein, the owners of a bakery called Sweet Cakes by Melissa, to pay $135,000 in damages to a lesbian couple for refusing, on religious grounds, to bake a cake for their same-sex wedding. He also ordered the Kleins “to cease and desist” from making statements that they would discriminate against anyone “on account of sexual orientation.”

The challenges facing conservatives are real. In recent decades, even as the GOP has racked up impressive gains in Congress, well-credentialed Republicans— George H.W. Bush, Bob Dole, John McCain, Mitt Romney—have lost bids for the White House, and George W. Bush lost the popular vote in 2000.

To preserve a conservative majority in Congress and to reassemble one that can win the presidency, conservatives must recover their appreciation of how social conservatism and limited-government conservatism fit together—and not just because neither alone can now muster a national majority. The two camps confront genuine tensions, but they form a coherent movement: Limited government protects the practice of traditional morality, and traditional morality educates individuals to take responsibility for their families and communities.

Some Republican presidential candidates seem to understand this imperative. It isn’t easy to say whether Jeb Bush, Marco Rubio and Scott Walker are social conservatives or limited-government conservatives. That’s good: Conserving the Constitution’s principles of liberty depends on blending and balancing the demands of both schools.

The candidates who take the stage in Cleveland in a few weeks shouldn’t speak as if today’s challenges to the conservative movement represent something entirely new. Nor should they underestimate the tasks ahead. Circumstances once again compel conservatives to apply their principles prudently to the world as it really is.

Mr. Berkowitz is a senior fellow at the Hoover Institution at Stanford University. His books include “Constitutional Conservatism” and “Virtue and the Making of Modern Liberalism.”

overlay image