WASHINGTON — Democrats maintain a strong position to retake the U.S. House, but the party’s base of less-frequent voters and concerns about illegal immigration stand out as wild cards in the final days before Tuesday’s midterm elections, according to a Washington Post-Schar School poll of likely voters in battleground congressional districts.

Overwhelming majorities of both Democrats and Republicans are confident their party will prevail, with both nearly as confident as Democrats were — erroneously, as it turned out — ahead of President Donald Trump’s surprise victory two years ago.

Voters also perceive high stakes in the event of a loss: At least two-thirds of Democrats and Republicans alike say a losing outcome for their party would be “very bad” for the country.

Across 69 congressional districts identified by the Cook Political Report and The Post as competitive in late August, the Post-Schar School poll finds 50 percent of likely voters support the Democratic candidate, while 46 percent support the Republican.

The Democrats’ four-point edge represents a superficial advantage with Republicans, given the poll’s 3.5-point margin of error. Still, the finding marks a sharp turn from 2016, when voters in these districts backed Republicans by a margin of 15 percentage points. With 63 of the battleground districts held by Republicans, that kind of shift in sentiment would be sufficient for Democrats to take control of the House. The party needs a net gain of 23 seats to win the majority.

The survey of 1,350 likely voters in battleground districts was conducted Oct. 25-28 and is the third wave of interviews in these districts this fall by The Post and George Mason University’s Schar School of Policy and Government. Few battleground voters shifted their support over that period, and Democrats’ four-point edge is identical to when these voters were first surveyed in September and early October.

Turnout remains a critical factor in Tuesday’s balloting, and given past patterns, Democratic turnout is at greater risk of falling short of what the candidates in competitive races might need to win. The party’s current level of support in the poll of battleground districts is fueled by a 21-point advantage among voters under age 40, a 21-point advantage among independents who lean toward neither party and a 40-point advantage among nonwhite voters. These groups have turned out at low rates in recent midterm elections.

In 2014, 36 percent of eligible African-Americans voted, along with 21 percent of Hispanics and 16 percent of people under age 30, according to the United States Elections Project. At the same time, 41 percent of whites cast ballots. And while some voters in these groups express heightened enthusiasm this year, it is unclear how much the electorate’s makeup will shift from previous years.

Overall, voters who did not turn out in the 2014 midterms favor Democrats by 55 percent to 42 percent, while those who did vote split 49 percent to 48 percent in Republicans’ favor.

Women continue to be key to Democratic hopes Tuesday.

White women with college degrees, a high-turnout group, favor Democratic House candidates, 62 percent to 36 percent. Along with nonwhite women, they contribute to a Democratic advantage among women overall, 54 percent to 42 percent. Republicans fare better among white women without college degrees, leading 55 percent to 42 percent. And Republicans have a slight edge among men, 50 percent to 47 percent.

Republicans draw roughly even support with other higher-turnout groups, among them seniors, who currently split 48 percent for Republicans versus 49 percent for Democrats. White voters, who make up a larger portion of the electorate in battleground districts this year, narrowly prefer Republican candidates, 51 percent to 47 percent.

The president’s increased focus on immigration may find some resonance with voters who will decide control of the House. The Post-Schar School poll finds that 54 percent of voters in battleground district say the “U.S. should do more” than it is currently doing to try to stop illegal immigration across the border with Mexico, while 21 percent support taking less action and 25 percent say the United States is already taking appropriate steps.

Attitudes, however, are sharply partisan, with 84 percent of Republicans and GOP-leaning independents saying the country should do more to prevent illegal immigration, compared with 23 percent of Democratic-leaning voters. Roughly half of independents say more should be done to deter illegal immigration.

The country’s increasing polarization and the hostile tone of the campaigns set the groundwork for the starkly negative views both parties have of a win by the other side. Roughly 9 in 10 Republican-leaning voters say it would be “bad for the country” if Democrats emerge with a majority in the House, including 67 percent who say it would be “very bad.” Similarly, more than 9 in 10 Democratic-leaning voters say it would be bad if Republicans maintain control, including 70 percent who see this as “very bad.”

Democratic-leaning voters are slightly more positive about winning, however. A 71 percent majority say it would be “very good” for the country if Democrats retake the House, compared with a smaller 56 percent majority of Republican-leaning voters who say the same about maintaining GOP control of the body.