COLUMBIA, S.C. -- One of U.S. President Donald Trump's earliest and strongest supporters, South Carolina Gov. Henry McMaster, survived an unusually tough challenge from a political newcomer on Tuesday. But a veteran Democratic House leader wasn't so fortunate.

Rep. Joe Crowley of New York lost to Alexandria Ocasio-Cortez, a 28-year-old former aide to the late Massachusetts Sen. Ted Kennedy, in the first defeat of the primary season for a Democratic incumbent.

In Utah, Mitt Romney, the former GOP presidential nominee and one-time face of the "Never Trump" movement, won the Republican nomination to run in November to become a 71-year-old freshman senator.

Crowley is the fourth-ranking Democrat in the House and had been considered a possible candidate to replace Nancy Pelosi as the party's leader in the chamber if the Democrats should win control in November and Pelosi should step aside.

Crowley was backed by many unions, while Ocasio-Cortez was endorsed by several liberal groups, including MoveOn.

Also in New York, Trump got his way where his preferred candidate defeated a convicted felon in the president's home city. Incumbent Rep. Dan Donovan beat former Rep. Michael Grimm,

Voters also went to the primary polls in Oklahoma, Mississippi, Maryland and Colorado.

No contest mattered more to Trump than South Carolina, where McMaster had faced the possibility of losing his seat to self-made Republican millionaire John Warren. The White House went all-in for the governor in recent days, dispatching the president and the vice-president to the state in an effort to prevent a political debacle.

Trump has a mixed track record when campaigning for other candidates: His preferred candidates have suffered stinging losses in Alabama and western Pennsylvania in recent months.

The South Carolina gubernatorial race headlined the latest series of primary contests across seven states. With the November general election a little more than four months away, more than half the states will have selected their candidates after the day's final votes are counted.

History suggests that Trump's Republican Party, like the parties of virtually every first-term president dating back to Ronald Reagan in 1982, will suffer losses this fall. Yet it remains unclear whether Democrats' enthusiasm advantage demonstrated in the early months of Trump's presidency will be enough to take control of Congress and key governors' offices nationwide.

Some of the Democrats who showed up to vote Tuesday were particularly motivated by the president's policy of separating immigrant children from their parents at the southern border -- a policy Trump reversed last week after an avalanche of criticism.

In New York City, Grimm's loss was good news for Trump.

Grimm had held the Staten Island seat until 2015, when he pleaded guilty to knowingly hiring immigrants who were in the country illegally to work at his Manhattan restaurant and cooking the books to hide income and evade taxes.

Given his political baggage, a Grimm victory would have jeopardized the seat in this fall's general election.

More than 2,000 miles (3,200 kilometres) away in deep-red Utah, former Massachusetts Gov. Romney faced little-known state Rep. Mike Kennedy, who questioned Romney's conservative credentials and ability to work well with the president. Kennedy won over far-right conservatives at the state GOP convention earlier in the year, but he was expected to struggle among more moderate Republican voters -- including many Trump critics -- around the state.

Utah voter Andrew Knaupp, a 43-year-old graphic designer, said he was irritated by Romney's early hostility to the president.

"I'm left wondering which Mitt Romney I'm going to get in office. He's changed his positions on a lot of things," Knaupp said, noting that he voted for Kennedy.

In a weekend op-ed published in The Salt Lake Tribune, Romney wrote that the Trump administration's policies have exceeded his expectations, but he pledged to "continue to speak out when the president says or does something which is divisive, racist, sexist, anti-immigrant, dishonest or destructive to democratic institutions."

Not to be forgotten: races to determine gubernatorial candidates in Maryland, Colorado and Oklahoma. Oklahoma was also deciding whether to legalize the cultivation, possession and use of marijuana for medicinal purposes.

In Maryland, the State Board of Elections was contacting as many as 80,000 voters whose registration information had not been updated, the result of a computer problem. Voters affected by the problem were asked to cast provisional ballots, which would not be counted until July 5, officials said. They added that the problem was related to a programming error, not infiltration from an outside source.

The most telling test of Trump's influence was in South Carolina, where McMaster -- elevated to the state's top office last year when Nikki Haley became U.N. ambassador -- had seemed in jeopardy. Two weeks ago, the governor failed to win the GOP primary outright, requiring a runoff election with Warren.

McMaster shocked even his closest advisers when, as lieutenant governor in early 2016, he became the first statewide-elected official in the country to back Trump's White House bid.

Warren, a millionaire businessman and a Marine, has argued that his outsider candidacy makes him more akin to Trump.

During a rally on the eve of the election, Trump dedicated only a few minutes of his hourlong speech to the Republican governor he was there to support. But McMaster got the image he wanted as he embraced Trump while they briefly shared the stage.

Peoples reported from New York. AP writers Brian Witte in Annapolis, Maryland, Lindsay Whitehurst in Salt Lake City and Deepti Hajela in New York City contributed.