For congressional Republicans, following the leader down a pragmatic path of compromise can get the followers in trouble back home, or worse, attract a more conservative opponent in the next primary election.

Conversely, attacking the leader wins points with the conservative base, as Mr. Cruz is counting on to catch up with Donald J. Trump, who has taken a lead in some polls by positioning himself as the most antiestablishment contender of all. Soon after attacking Mr. McConnell on Friday, Mr. Cruz dialed into the radio shows of the conservative celebrities Rush Limbaugh and Mark R. Levin. Mr. Limbaugh called the Cruz attack “Mr. Smith Goes to Washington-type stuff.” Mr. Levin posted on Twitter, “Let’s see how many others in the Senate have a backbone & call out McConnell.”

The roots of the current base-versus-establishment dynamic go back two decades, after Republicans broke Democrats’ 40-year lock on a House majority in 1994. The party’s base had shifted to the more conservative and populist South from the Northeast and Midwest. Also, conservative media was popular and expanding: Its initial alliance with the Republican establishment was evident when party leaders, including Mr. Boehner, made Mr. Limbaugh an honorary House Republican for his role in helping make them a majority.

Like Mr. Boehner, many in today’s party establishment once were proud troublemakers for conservatism themselves — Mr. Weber was, along with Newt Gingrich, a leader among right-wing rebels in the House through the Ronald Reagan and George Bush administrations — and they remain conservative still by any nonpartisan measure. But governing often means compromising.

By the early 2000s, conservative voters grew increasingly antagonistic toward party leaders, and so did the conservative media that both reflects and drives opinion among its hard-line audience. With Republicans in control of both the White House and Congress for six years, many conservatives were disillusioned and angered by the George W. Bush era’s legacy of deficits, mismanagement in Iraq and during Hurricane Katrina, recession, financial collapse and federal bailouts.

The election of Mr. Obama and a Democratic-controlled Congress for a time caused Republicans to unite in opposition, and Mr. Obama’s policies, like the Affordable Care Act, gave rise to the Tea Party. Republicans won a House majority again in the 2010 midterm elections with an influx of Tea Party supporters.