MILLBROOK, Ala. — U.S. Rep. Martha Roby won Alabama's Republican runoff, fighting through lingering fallout from her years-old criticism of then-candidate Donald Trump in a midterm contest that hinged on loyalty to the GOP president.

The four-term incumbent will now represent the GOP on the November ballot having defeated Bobby Bright, a former Democrat who tried to cast himself as the more authentic Trump ally in the low-turnout Republican contest.

The Trump White House was on Roby's side.

Congratulations to Martha Roby of The Great State of Alabama on her big GOP Primary win for Congress. My endorsement came appropriately late, but when it came the “flood gates” opened and you had the kind of landslide victory that you deserve. Enjoy! — Donald J. Trump (@realDonaldTrump) July 18, 2018

"It's been a true privilege to have the support of the White House through this campaign," Roby told cheering supporters Tuesday night, her voice cracking with emotion at times. "I am so humbled that the people of Alabama's 2nd Congressional District have again placed their trust and their confidence in me."

Trump and Vice President Mike Pence endorsed the four-term incumbent in recent weeks. The vice president went further over the weekend and recorded robocalls distributed on her behalf saying she's a reliable vote for the Trump agenda.

Some intervention was required after Roby angered Alabama Republicans in the closing days of the 2016 presidential election when she said Trump's lewd comments about women — captured on an "Access Hollywood" tape — made him unacceptable as a candidate for president.

Bobby Bright is embraced by his wife, Lynn, after announcing his retirement from politics at a watch party in Prattville, Alabama, following his runoff loss to Roby on Tuesday. Vasha Hunt / AP

She spent much of the last two years trying to convince her constituents in Alabama's 2nd Congressional District that she was sufficiently loyal to Trump.

Trump's support did not guarantee a victory, of course, even in a deep-red district that overwhelmingly backed him two years ago. The president has a mixed record this primary season, having backed a handful of Republican candidates in friendly districts who ultimately lost.

The most noteworthy, perhaps, was Alabama's own Republican Senate candidate Roy Moore, who earned the president's strong backing but suffered an embarrassing loss just eight months ago.

Voters indicated they were willing to move past Roby's criticism of Trump.

Don Bascom, a retired mechanical engineer who lives in Prattville, said he generally supports the president, but he also shared Roby's concerns about him in 2016. He voted for the congresswoman on Tuesday.

"I think she has done a good job. She's an incumbent so to some degree she's proven herself," he said. "One of the criticisms I've heard of her is that she simply couldn't vote for Trump when he ran, and to be honest, I couldn't either because of the way he treats people."

Deborah Gilliam, a registered nurse from Millbrook, said she too was bothered by Roby's comments about Trump, but she ultimately voted for her. She said she felt uneasy with Bright's party switch.

"It was a toss-up," Gilliam said. "I'll give her one more chance."

Roby faced the runoff test because she earned only 39 percent of the vote in the first primary contest back in June. Bright was the second-place finisher.

Despite her past criticism of Trump, the White House eventually emerged as Roby's most powerful backer.

Trump called Roby a "reliable vote for our Make America Great Again Agenda" on Twitter and bashed Bright as "a recent Nancy Pelosi voting Democrat."

The president was referring to Bright's support of Pelosi's bid to become House speaker when he was a Democrat in Congress.

Roby made clear she would return the favor should she win re-election in November, as widely expected in heavily Republican state. She'll face Democrat Tabitha Isner, a political newcomer.

"It has been a great privilege to be a part of the conservative momentum and to work alongside my colleagues in Congress and the Trump administration," Roby told supporters Tuesday night. "I am ready to continue the fight."