Sen. Orrin G. Hatch and Rep. Charles B. Rangel, two longtime lawmakers who saw their careers imperiled by the shifting political winds, cruised to primary victories Tuesday night despite stiff challenges from younger upstarts.

Hatch, a conservative Utah Republican, and Rangel, a liberal New York Democrat, have nearly eight decades of incumbency between them. But both lawmakers faced their toughest primary challenges ever this year, becoming the latest examples of longtime politicians struggling to adjust to a new political reality.

Hatch, a six-term senator, ran what many GOP strategists considered a strong campaign against a tea-party-backed opponent, providing a possible road map for other Republican incumbents facing similar primary challenges in the coming years. The race was another example of an ideological divide that has framed the debate about the future of the GOP for much of the past year.

Rangel, a 42-year member of the House and former chairman of the Ways and Means Committee, was tripped up by ethics rules that were stricter in recent years than when he began his career in Congress, and colleagues rebuked him on the House floor 18 months ago. It was the chamber’s first censure of a member in nearly three decades.

Hatch entered Tuesday in a stronger position and was quickly declared the winner as early returns showed him leading by nearly 40 percentage points. With more 80 percent of the precincts reporting, Rangel led his closest rival, state Sen. Adriano Espaillat, 47 percent to 38 percent, with three other candidates splitting the remaining votes.

Rangel, the dean of the New York congressional delegation and one of the founding members of the Congressional Black Caucus, also was threatened by redistricting and related demographic shifts.

Sometimes referred to as the “congressman from Harlem,” Rangel has been an influential voice on issues important to black voters everywhere. But a majority of the voters in his newly drawn district are Hispanic. Rangel spent his final days of the primary campaign targeting Puerto Rican voters in his bid for a 22nd term. He faced a strong challenge from Espaillat, 57, who would have been the first Dominican American in Congress.

“Am I too old to run for reelection?” Rangel, 82, who missed two months of work in the winter after a virus left him unable to walk, asked reporters rhetorically after casting his vote. He did a slight dance move as supporters chanted his name, predicting that “we’re going to win this one.”

Both Hatch and Rangel — the former a devout Mormon from deeply red Utah and the latter raised by a single mother during Harlem’s heyday of influence on African American culture — are known for their ideological verve but also have long histories of bipartisan deal-making in a broad range of areas, including health-care legislation and international trade deals. Both are virtually guaranteed to win in the November general election.

Unlike in the not-so-distant past, when longtime lawmakers of their stature would have cruised through their parties’ primaries, Hatch and Rangel joined the ranks of a growing number of incumbents who were forced into battles against up-and-coming opponents and outside interest groups dedicated to upending the establishment in both parties.

FreedomWorks, one of the main political financiers of the tea party movement, spent nearly $900,000 to boost Hatch’s challenger, former state legislator Dan Liljenquist. A super PAC spent $100,000 on behalf of one of Rangel’s opponents, the lion’s share coming from one wealthy donor, and an anti-incumbent super PAC spent $12,000 on direct mail and e-mail messages targeting Rangel.

In addition to Rangel, 10-term Rep. Nydia Velazquez (D) was declared the winner after facing several challengers in a district that now takes in portions of three New York boroughs. With nearly 90 percent of the vote in, she bested her closest rival, 62 percent to 25 percent.

Primary voters in Colorado and Oklahoma also went to the polls Tuesday to choose party nominees for November. Rep. Doug Lamborn (R), one of the most conservative lawmakers, beat back a challenge from wealthy businessman Robert Blaha, who collected less than 40 percent of the vote despite spending $750,000 of his own money.

In a new district in South Carolina, Horry County Councilman Tom Rice, who received the late backing of Gov. Nikki Haley in the GOP primary runoff in the state’s new 7th Congressional District, defeated former lieutenant governor Andre Bauer for the party’s nomination Tuesday. Rice will face upstart Gloria Bromell Tinubu, a little-known former Georgia legislator who moved back to South Carolina last year and easily defeated the establishment-backed candidate, Preston Brittain.

Hatch’s campaign may become a model for Senate GOP incumbents in the future, having run a tough campaign after watching Republican veterans fall in Utah’s odd primary system in 2008 and 2010. Instead, Hatch emerged from Utah’s GOP convention two months ago with nearly 60 percent of the vote, a forum in which about 4,000 activists vote, compared with Tuesday’s statewide primary in which nearly 200,000 cast ballots.

In Washington, senior Republicans noted Hatch's aggressive campaign. “It’s like the old Boy Scout motto: Be prepared,” said Sen. John Cornyn (Tex.), chairman of the National Republican Senatorial Committee.

Cornyn, who will face a reelection race in 2014, said that other Republicans were contrasting Hatch’s performance with that of Sen. Richard G. Lugar (Ind.), who lost his primary last month after what many considered a lackluster effort, and former senator Robert F. Bennett (Utah), who lost the GOP nomination in 2010 along with a few other Republican establishment candidates to tea-party-supported challengers.

“People with eyes to see and ears to hear, I don’t know how they could miss that message,” Cornyn said of Hatch. “Because we’ve seen both people who’ve done it well and people who have not done it as well, with obvious differences in outcomes.”

If Hatch wins and completes another six-year term, his 42 years in the Senate would make him the longest-serving GOP senator in U.S. history.