(Adds details of poll closures; few reports of voting technology failures)
By John Whitesides
WASHINGTON, Nov 6 (Reuters) - Americans voted on Tuesday to decide whether Donald Trump's Republicans maintain their grip on the U.S. Congress, or if Democrats can slow the president's agenda after a divisive campaign marked by clashes over race, immigration and trade.
The first national elections since Trump captured the White House in a stunning 2016 upset is a referendum on the polarizing president and a test of whether Democrats can turn the energy of the liberal anti-Trump resistance into victories at the ballot box.
The Democrats have a good chance of winning at least the U.S. House of Representatives and slimmer hopes of gaining control of the Senate, opinion polls show.
If they do take the House, Democrats could launch congressional investigations into aspects of Trump's administration from his tax returns to possible conflicts of interest, challenge his overtures to Saudi Arabia, Russia and North Korea, and oppose him on immigration, tax cuts and trade.
If Republicans hold onto both chambers of Congress, Trump likely would claim vindication for his polarizing style, a month after he secured a conservative majority on the Supreme Court when the Senate approved nominee Brett Kavanaugh after a fight over sexual misconduct accusations that split the nation.
Striking a dark tone at a rally in Indiana on Monday evening, Trump accused Democrats of "openly encouraging millions of illegal aliens to break our laws, violate our borders and overrun our country."
All 435 seats in the House, 35 Senate seats and 36 governorships are up for grabs in elections focused on dozens of competitive races that opinion polls show could go either way.
Democrats are favored by election forecasters to pick up the minimum of 23 House seats they need for a majority.
The first polling stations close at 6 p.m. Eastern time (2300 GMT) with early results expected shortly after but a full picture likely will not begin to emerge until late at night.
Republicans are expected to retain their slight majority in the Senate, currently at two seats, which would let them retain the power to approve U.S. Supreme Court and other judicial nominations.
U.S. stocks ticked higher in thin trading on Tuesday, as investors awaited the election results.
Political gridlock between the White House and Congress could hinder Trump's pro-business agenda and raise concerns about U.S. political instability, but investors may have already priced this in.
Analysts expect pressure on stocks if Democrats gain control of the House and a sharper downward reaction if they win the Senate, too. If Republicans hold their ground, stocks could gain further, with hopes of more tax cuts ahead.
In a last-minute controversy, NBC, Fox News and Facebook on Monday pulled an ad by Trump's campaign that critics have labeled racist. The spot featured courtroom video of an illegal immigrant from Mexico convicted in the 2014 killings of two police officers, juxtaposed with scenes of migrants headed through Mexico.
Critics, including members of Trump's own party, have condemned the commercial as racially divisive. CNN had already refused to run the ad, saying it was racist.
Voter turnout in national elections, normally lower when the White House is not at stake, could be the highest for a midterm election in 50 years, experts predicted. About 40 million early votes were likely cast, said Michael McDonald, a professor at the University of Florida who tracks the figures. In the last such congressional elections in 2014, there were 27.5 million early votes.
“I have worked at this poll the last three elections and this is the biggest turnout ever," said Bev Heidgerken, 67, a volunteer at a polling place in Davenport, Iowa. "We usually hope for 200 voters for the entire day but by 9 o'clock we already have had 69."
There were sparse reports of voting technology failures on Tuesday and they appeared so far to have had no significant impact in preventing people from voting, a Department of Homeland Security official said.
At least 64 House races remain competitive, according to a Reuters analysis of the three top non-partisan forecasters, and Senate control was expected to come down to a half dozen close contests in Arizona, Nevada, Missouri, North Dakota, Indiana and Florida.
In his time in office, Trump has pushed tax cuts through Congress and overseen a period of economic and jobs growth but has failed so far to deliver on presidential campaign promises to replace the Obamacare healthcare law and build a wall on the Mexican border against illegal immigration.
A Democratic victory in the House would further hinder the border wall plan and complicate congressional approval of a deal to update the North American Free Trade Agreement.
Trump also could face more pushback from Democrats on trade tariffs he has introduced, particularly in farm states hard hit by retaliatory measures from China or manufacturing states hit by higher steel and aluminum prices.
Wrapping up the campaign in recent days, Trump repeatedly raised fears about immigrants, issuing harsh warnings about a caravan of Central American migrants that is moving slowly through Mexico toward the U.S. border.
In affluent Newport Beach, California, Russ Buller voted for Republican Dana Rohrabacher in a U.S. House race and voiced support for Trump.
“I love him," the 40-year-old stay-at-home dad said of the president. "Sometimes he comes across as insensitive but he’s saying what a lot of people are thinking."
A debate about whether Trump's rhetoric encouraged extremists erupted in the campaign's final weeks after pipe bombs were mailed to his top political rivals allegedly by a Trump supporter who was arrested and charged, and 11 people were killed in a shooting at a Pittsburgh synagogue.
Many Democratic candidates in tight races shied away from harsh criticism of Trump, focusing instead on bread-and-butter issues like health insurance and safeguarding the Social Security retirement and Medicare healthcare programs for senior citizens.
That message resonated with voter Clemente Escalante, 74, a retiree.
"They (Republicans) have been trying to take Medicare away from us, our medical services, and it’s important that we vote for candidates who will defend that,” he said at a polling place in Tornillo, Texas. The deeply conservative state features a strong challenge by Democrat Beto O'Rourke to unseat U.S. Senator Ted Cruz.
Democratic former Vice President Joe Biden called on Americans to use their votes to reject Trump.
"This is the single most important off-year election of my lifetime. I really think it's more than just about a specific issue. I think it's about the character of the country," he said in Wilmington, Delaware, where he voted.
Democrats also could recapture governor's offices in several battleground states such as Michigan, Wisconsin and Ohio, a potential help for the party in those states in the 2020 presidential race.
Reporting by John Whitesides Additional reporting by Susan Heavey, Steve Holland, Roberta Rampton, Eric Beech and David Alexander in Washington, Julio Cesar Chavez in Texas and John Peragine in Iowa and Sharon Bernstein in California Writing by Alistair Bell Editing by Frances Kerry and Bill Trott