Mississippi voters send Hyde-Smith back to the US Senate after a runoff marred by controversy Republican Sen. Cindy Hyde-Smith defeats Democrat Mike Espy in a midterm finale.

Mississippi has elected its first woman to Congress in the state's history.

Sen. Cindy Hyde-Smith thwarted an against-the-odds challenge from Democrat Mike Espy, the Associated Press has projected. Espy mounted an aggressive campaign for the last remaining Senate seat of 2018, but the race became surprisingly competitive in its final weeks after numerous missteps by Hyde-Smith, including recently revealed controversial comments that harkened back to the state's racially-charged history.

In a short victory speech to supporters Tuesday night, Hyde-Smith called it "unbelievable night."

"The reason we won is because Mississippians know me, and they know my heart," she said to a crowd of supporters in Jackson. "No matter who you voted for today, I’m going to always represent every Mississippian."

After celebrating her win on stage, Hyde-Smith elaborated on her controversial remarks, telling reporters, "We have apologized for that, we’re going to move on and go forward."

In the most extensive response to a series of controversies that drew national attention to the race, she defended her "public hanging" comments by saying, "I’m a cowgirl and when a cowgirl references western movies that I've seen hundreds of, and somebody twists it, that's just it, you’ve gotta roll with the punches."

President Donald Trump, who endorsed Hyde-Smith throughout the election, sent out a congratulatory tweet soon after her win Tuesday night.

Moments before Hyde-Smith spoke, Espy took the stage before a sober crowd in the Mississippi Civil Rights Museum in Jackson and told the audience of his opponent, "She has my prayers to unite a very divided Mississippi. She has my prayers and willingness to help her."

In the wake of his defeat, Espy delivered a message of hope to his supporters, "We built the largest grassroots organization that our state has ever seen in a generation. We did that through a coalition of voters, white and black, who shared a belief that Mississippi's future will be brighter than Mississippi's past. Make no mistake, tonight is the beginning. Tonight is not the end."

"When this many people show up, when this many people stand up, when this many people speak up, it is not a loss, it is a movement," he asserted.

Amid a swarm of national attention, a series of controversies surrounding Hyde-Smith put her candidacy under intense scrutiny and sparked concerns among the Republican Party that her lead over Espy was tightening.

Tuesday's runoff was supposed to be a procedural hurdle for Hyde-Smith and for Republicans hoping to expand their Senate majority 53-to-47 over Democrats and to hold onto former Sen. Thad Cochran's seat. He resigned in April due to health concerns.

But a "jungle primary" format in the special election allowed for multiple contenders from both parties to compete for the open seat for the remaining two years of Cochran's term. Hyde-Smith needed to secure more than 50 percent of the vote to win on Nov. 6, but instead, Espy benefited from the two Republican contenders -- Hyde-Smith and state Sen. Chris McDaniel -- splitting the GOP vote. Espy garnered 40.6 percent of the vote, only 0.8 percent behind Hyde-Smith, and McDaniel netted about 16 percent.

Trump held two rallies for Hyde-Smith on Monday, hoping to shore up support for the Republican in a deep red state he won by nearly 18 points in the 2016 election.

"Tomorrow the voters of this state will cast their ballots and one of the most important Senate elections of your lives of all of our lives," the president told a crowd of supporters in Tupelo Monday evening, "I'm here to ask the people of Mississippi to send Cindy Hyde-Smith back to the United States Senate."

A generic get out the vote robocall of former President Barack Obama was also released Monday night in Mississippi, appearing to support Mike Espy in the Senate special election, although the call does not mention Espy by name.

"Hi, this is Barack Obama and tomorrow is Election Day. My name might not be on the ballot but our future is and that's why I believe this is one of the most important elections in our lifetime. Make a plan to vote tomorrow. I'm counting on you to be in line to vote before polls closed," the former president said in a copy of the recorded call posted by the National Journal.

The end of the robocall states it was paid for by Espy's PAC, Mike Espy for Senate Campaign Committee.

Hyde-Smith, a former state lawmaker and agriculture commissioner who was appointed to the seat following Cochran's resignation, has faced fierce blowback over a racially tinged joke about "public hangings" that became public after a video taken by a political tracker following her campaign posted it to Twitter.

In the first and only debate in the race, Hyde-Smith read an apology from her notes to "anyone offended by my comments," but has not expanded beyond that on the controversy.

The fallout for Hyde-Smith continued leading into the runoff as high-profile companies withdrew their support for the senator, by requesting refunds of contributions that ranged from $2,000 to $5,000.

Google and Facebook have joined the growing list of companies distancing themselves from Hyde-Smith, including Walmart, Major League Baseball, Pfizer, Union Pacific, Amgen, AT&T, dLeidos and Boston Scientific.

On Monday, seven nooses were left hanging on a tree near the Mississippi State Capitol and state and federal investigators are looking into who is responsible. Hyde-Smith's campaign refused to comment on the status of the donations after repeated requests from ABC News.

The nooses were accompanied by signs that made reference to Tuesday's election as well as lynching. The Mississippi Department of Public Safety posted photos of the signs on social media Monday seeking more information about the perpetrators.

Mississippi's Republican Gov. Phil Bryant issued a statement Monday saying the people responsible will be found and punished.

"The perpetrators of this act will be identified and prosecuted to the fullest extent of the law. I have contacted the Department of Public Safety and the Federal Bureau of Investigation for assistance," Bryant wrote in a statement.

But Hyde-Smith's controversies did not stop at her "public hanging" remark.

The Republican also took heat after photos surfaced on Facebook showing Hyde-Smith donning a Confederate soldier hat, with the caption "Mississippi history at its best."

Hyde-Smith's campaign declined to comment to ABC News on the photos.

A fixture in Mississippi politics for most of the past two decades, Hyde-Smith was a registered Democrat until switching parties in 2010 while she was a member of the Mississippi State Senate. She went on to win election as the Mississippi Commissioner of Agriculture in 2011 and was re-elected to the position in 2015.

She has closely aligned herself with Trump throughout her campaign, and has a 100 percent "Trump score," a measure of how often a member votes in line with Trump’s position, according to FiveThirtyEight.

Espy, a former congressman and secretary of Agriculture under former President Bill Clinton, edged closer into competitive territory. The national Democratic network mobilized in the hopes of delivering a potential upset and has cast his opponent's controversial comments as an embarrassment to a state whose history has often been defined by racism and racially-motivated violence.

"It’s caused our state harm," Espy said in a debate earlier this month, "It’s given our state another black eye that we don’t need. It’s just rejuvenating those stereotypes that we don’t need anymore."

As a red state Democrat in the south, Espy’s task was a balancing act: embracing the core of his voters who he can help propel him back into national politics, while also convincing more moderate voters of his political independence.

Using his moderate appeal to attract white voters, Espy called himself an "independent" Democrat.

"Even though I'm a Democrat, I'm an independent — a small 'I' — Democrat, meaning that I'm a Mississippian first," Espy told ABC News in an interview last month.

But Espy still faced an uphill battle. Mississippi has not elected a Democrat to the U.S. Senate since 1982, and has not voted for a Democratic presidential candidate since former President Jimmy Carter in 1976.

The Democrat also contended with criticism during the race for allegedly lying about a lobbying contract with the government of the Ivory Coast and work with an African despot who refused to give up power and is now on trial for crimes against humanity. Espy's campaign says he terminated any relationship with the client when doubts arose.

"Secretary Espy worked on agricultural issues for international clients. Over the course of that work, he realized one of those clients didn't pass the smell test, so he terminated the contract, and then reported what he knew to the U.S. government," Danny Blanton, communications director for Espy's campaign, said in a statement first to Fox News and confirmed by ABC News.

Espy addressed the report at the Nov. 20 debate, stating in a rebuttal, "I found out later that this guy, the president, was a really bad guy."

"I resigned the contract and I rescinded the last fee that I was due," he continued. "Then I went to the Central Intelligence Agency that I learned certain things, and I recorded them."

The unexpected shift in tenor of the race in favor of the former agriculture secretary was boosted by potential 2020 contenders such as Sen. Kamala Harris of California, Sen. Cory Booker of New Jersey and former New Orleans Mayor Mitch Landrieu in the final weeks. They traveled to the state to stump with Espy — who hoped to deliver a potential upset similar to Alabama Sen. Doug Jones' seismic victory over Republican Roy Moore.

A win for the GOP expanded their current razor-thin margin that, at times, seemed to hamper their agenda prior to the midterm elections, by an additional seat.

In the new Congress, after Democrats flipped nearly 40 seats and gained a comfortable majority in the House, a win in Mississippi is the ending Trump needs to halt Democrats' momentum before his name is back on the ballot in 2020.