WASHINGTON — Two congressional veterans survived career-threatening primary challenges Tuesday night as voters weighed in on races that could help define the next Congress.

In Utah, Republican Sen. Orrin G. Hatch handily fended off a tea party opponent, while in New York’s Harlem, legendary Democratic Rep. Charles B. Rangel emerged from one of the tougher fights of his 42 years in office.

Neither race is considered an opportunity for the opposing party this fall. But the primaries provided an early glimpse of the electorate’s attitudes.

“Voters aren’t happy with Congress [and] aren’t happy with the direction of the country, but there isn’t an anti-incumbent wave that is sweeping the country,” said Nathan Gonzales, deputy editor of the nonpartisan Rothenberg Political Report in Washington. “Even though incumbents are unpopular, they continue to win their primaries.”

Hatch’s tea party opponents had poured money and resources into the race in hopes of repeating their surprise 2010 victory over Sen. Robert F. Bennett (R-Utah), which helped fuel the movement’s victories nationwide. Hatch, 78, had been preparing for this day ever since.

Hatch, who was first elected to the Senate in 1976, began tacking further to the right in his votes and commentary to shore up support. In seeking a seventh term, he outspent opponent Dan Liljenquist almost 10 to 1. And although Liljenquist, a former state senator, was the tea party favorite, Sarah Palin endorsed Hatch.

“Today was a great win for me and my campaign, and I couldn’t be more pleased to see our hard work pay off,” Hatch said in a late-night statement.

The Utah contest is a reminder that campaigns matter, GOP strategists said. They pointed to Sen. Richard G. Lugar of Indiana, another veteran Republican challenged by the right flank. Lugar’s loss earlier this year was attributed as much to his campaign, which critics said was out of touch, as to any groundswell of tea party fervor.

The New York race, meanwhile, offered a lesson of a different sort: that politics are, indeed, local.

Turnout was key as Rangel, a founding member of the Congressional Black Caucus, faced several challengers for the Democratic nomination. Since redistricting, his district includes a swath of the Bronx — and a Latino-majority electorate.

Rangel, who turned 82 this month, had to contend with shifting demographics that are splitting the electorate along racial lines.

His strongest opponent was state Sen. Adriano Espaillat, an up-and-coming Dominican American leader who had the backing of the president of the Dominican Republic. Espaillat came in second.

“A big thank you to all my supporters and everyone else who had the courage to come out and vote today,” a message on Rangel’s campaign Twitter account read.

Democrats in Washington largely backed Rangel, although President Obama refrained from endorsing him in the primary. So did former President Clinton, whose office is in Harlem, despite recording a birthday greeting for the man he called “my congressman.” Gov. Andrew Cuomo supported him.

Rangel, a high school dropout who became a Korean War hero, a law school graduate and dean of the New York congressional delegation, has had health problems in the last year.

This may be the final run for both candidates. Hatch has said he will not run again if he wins in November, and many insiders also expect this to be Rangel’s last bid for Congress.

lisa.mascaro@latimes.com