Ms. Love raised the money during the primary period, even though she knew she would have no primary challenger after she won the nomination at the party convention in April. Her campaign called the complaint “completely false and desperate” but agreed to redesignate $372,000 for her general election campaign and pay back up to $10,000.

Ms. Love’s unique profile — daughter of Haitian immigrants, a convert to the Mormon Church and the only Republican member of the Congressional Black Caucus — presented a challenge to Democrats who sought to depict her as a Trump loyalist.

She did not enlist the president’s help in her campaign, which he seemed to interpret as a snub.

At a televised news conference the day after votes were cast, Mr. Trump attacked Republicans who lost their seats for what he saw as their insufficient support of him and his agenda. The result of Ms. Love’s race was still days from being called, but Mr. Trump scornfully lumped her in with the losers anyway.

“Mia Love gave me no love, and she lost,” Mr. Trump told reporters. “Too bad. Sorry about that, Mia.”

Mr. McAdams rode to victory in the Fourth District — which includes a slice of progressive Salt Lake City but extends south to incorporate a string of more conservative cities and towns in Juab, Sanpete and Utah Counties — in part thanks to his record as mayor of Salt Lake County, which covers 85 percent of the district.

The city has emerged as a progressive oasis in recent years, and Mr. McAdams has positioned himself as a centrist able to meet the needs of its disparate constituencies. They include immigrants, gay people, religious conservatives, tech employees and investors arriving from out of state.

Mr. McAdams became well known for negotiating a deal among Republicans, religious leaders and the gay community on a nondiscrimination ordinance, and worked with Republicans in the State Legislature to alleviate homelessness in the region. As part of that effort, Mr. McAdams secretly posed as a homeless man for three days.

For her part, Ms. Love portrayed Mr. McAdams as the politician who was out of touch with the district, casting him as a liberal supporter of Hillary Clinton and abortion rights who would not represent the wishes of Utahns in Congress. In the end, it was not enough.