On Tuesday, the president said that he was preparing an executive order that would eliminate birthright citizenship for children of noncitizens and undocumented immigrants. The comments, which represent a legal view at odds with mainstream scholars , drew rebukes from the right and left. Earlier Wednesday, the president said the matter would be settled by the U.S. Supreme Court.

"Paul Ryan should be focusing on holding the Majority rather than giving his opinions on Birthright Citizenship, something he knows nothing about!" the president said. "Our new Republican Majority will work on this, Closing the Immigration Loopholes and Securing our Border!"

President Donald Trump on Wednesday ripped Speaker of the House Paul Ryan , R-Wis., a day after Ryan said the president could not eliminate birthright citizenship with an executive order. The comments come just six days before the midterm elections.

"You cannot end birthright citizenship with an executive order," Ryan said in an interview with a Kentucky radio station Tuesday. "We didn't like it when Obama tried changing immigration laws via executive action, and obviously as conservatives, we believe in the Constitution."

Ryan, who has raised north of $70 million for Republican candidates this cycle, made the comments while campaigning for Rep. Andy Barr, R-Ky., who is facing a tough re-election challenge from Democrat Amy McGrath.

The president's comments come as the GOP faces down long odds of retaining its majority in the House of Representatives. Democrats need to net 23 Republican-held seats in order to flip the chamber. It's a prospect that pollsters say is likely to happen.

Rep. Nancy Pelosi, D-Calif., the top-ranking Democrat in the chamber, in recent days has expressed increasing confidence that her party could net as many as 30 seats next week.

"What now I'm saying is, we will win. We will win," Pelosi said Tuesday night in an appearance on the CBS program "The Late Show with Stephen Colbert."

The president has, at different times, claimed varying levels of responsibility for how his party will do in the first midterms of his presidency.

At campaign rallies, he has told supporters that voting for Republicans on Tuesday means "you're voting for me." In an interview with The Associated Press earlier this month, however, the president said he would not be responsible for a GOP defeat.

In that interview he emphasized the importance of the Republican majority to his legislative successes.

"I like the Republicans that support me in Congress," the president said. "We've had tremendous support. I mean, we've got the taxes with 100 percent Republican votes and we don't really have much of a majority."

"People have no idea," Trump said, about how well he got along with Republicans in Congress.

— CNBC's Brian Schwartz and Kevin Breuninger contributed to this report.