WASHINGTON—White House officials are divided over whether President Trump should declare a national emergency to obtain funding to build a border wall and end a partial government shutdown, but were exploring how the president could divert funding if he decides to do so.

The White House has asked the Army Corps of Engineers to examine potentially diverting money from other projects to pay for the wall along the U.S.-Mexico border, if Mr. Trump does decide to declare a national emergency. The administration is also exploring having the Department of Homeland Security request the funds from the Pentagon so that it can carry out its mission.

Inside the West Wing, Jared Kushner, the president’s son-in-law and senior adviser, has been lobbying for restraint, according to White House officials. Declaring a national emergency, an option Mr. Trump has been leaning toward, shouldn’t be used to try to win a messaging war against Democrats opposed to a wall, Mr. Kushner said in a recent Oval Office meeting, these officials said.

Instead, Mr. Kushner argued an emergency should be invoked only if it creates a clear path for the White House to build the wall, the key issue in the standoff between Mr. Trump and congressional Democrats that has led to the shutdown. “Let’s stop doing things just to do them,” Mr. Kushner said, according to officials familiar with the meeting.

Kellyanne Conway, Mr. Trump’s counselor, is also among the voices urging caution, saying a national emergency would “let Congress off the hook,” officials said.

The internal debate was ongoing Thursday, the 20th day of the shutdown, as Mr. Trump traveled to McAllen, Texas, to meet with Border Patrol agents working without pay. Later, Mr. Trump said he was canceling his late January trip to the World Economic Forum in Davos, Switzerland, citing the border-security and shutdown negotiations.

Mr. Trump, while saying he would still seek a compromise, views the emergency move as the most efficient way to end the lapse in federal funding, according to people familiar with his thinking. The shutdown will become the longest in U.S. history if it lasts until Saturday. Under such a scenario, Mr. Trump could sign a spending bill to reopen the government, while his emergency declaration would face immediate legal challenges.

“I probably will do it—I would almost say definitely,” Mr. Trump said Thursday.

President Trump has suggested he might resort to declaring a national emergency to fund a wall at the border with Mexico. But what constitutes a national emergency and how might funding work? Jason Bellini reports. Photo: Getty

Some GOP lawmakers said Congress could take action to block such a move or at least issue a rebuke. Congressional aides said Thursday they are researching the legislative process, as lawmakers raise concerns that the precedent set by Mr. Trump, a Republican, would apply to a future Democratic president.

Acting White House chief of staff Mick Mulvaney is among those internally pushing for Mr. Trump to declare an emergency, officials said. About two months before he resigned, Defense Secretary Jim Mattis told Mr. Trump that a national emergency was a realistic option and that the Pentagon could help get the wall built, according to people briefed on the conversation. Mr. Mattis couldn’t be reached for comment on Thursday.

Under one option under consideration if Mr. Trump declares a national emergency, the White House has asked the Army Corps of Engineers to look into projects approved in a February 2018 bill providing disaster relief for Puerto Rico, Texas, California and Florida to see whether funding could be diverted to build the wall, said a congressional aide familiar with the talks.

Federal law allows the president to halt military construction projects and divert those funds for an emergency.

Another option being explored by the White House is having the Department of Homeland Security request the funds from the Pentagon so that it can carry out its mission. This sort of scenario took place last fall, when the department formally asked the Defense Department to provide troops to help safeguard the southern border. Mr. Mattis approved the request.

One drawback to this approach is that it would tap into money that the Defense Department has set aside for military readiness, a defense official said Thursday.

If Mr. Trump invokes a national emergency, he risks angering some conservative allies, who may view it as an abuse of executive power.

Rep. Matt Gaetz (R., Fla.), who has spoken with Mr. Trump about the possibility of declaring a national emergency, expressed concern over him taking such bold executive action. Republicans—including Mr. Trump himself—were sharply critical of former President Obama’s exercising of executive power in dealing with immigrant children brought to the U.S. illegally by their parents, among other issues.

Things have gotten nasty between President Trump and congressional Democrats over the government shutdown. But there could be ways out of the current stalemate. WSJ's Gerald F. Seib explains. Photo: Getty

“I don’t want the next national emergency to be that some Democrat president says we have to build transgender bathrooms in every elementary school in America,” Mr. Gaetz quipped.

Invoking a national emergency in hopes of bypassing Congress also could boomerang, provoking lawmakers to pass legislation curbing the president’s executive power, said Alberto Gonzales, who served as attorney general and White House counsel under GOP President George W. Bush.

The House also could pass a resolution of disapproval aimed at terminating Mr. Trump’s declaration, and the measure would need a simple majority to pass through the GOP-held Senate, though aides are still researching the process. Mr. Trump could still veto the measure, but the debate would likely continue to postpone any construction, as would an expected lawsuit by Congress.

An effort on Capitol Hill among centrist Republican senators to cobble a compromise collapsed on Thursday. “It’s very difficult when we’re dealing with people who do not want to budge at all in their positions, and that’s the president and Speaker [Nancy] Pelosi,” said Sen. Susan Collins (R., Maine).

Mrs. Pelosi declined on Thursday to elaborate on the legal action that House Democrats would take if Mr. Trump declared a national emergency.

“If and when the president does that, you’ll find out how we will react,” the California Democrat said, adding that “the president will have problems on his own side of the aisle for exploiting the situation in a way that enhances his power.”

Mr. Trump has complained to his aides that “something has to happen,” according to a person close to the White House. White House officials involved in the negotiations increasingly believe that Mr. Trump will make the emergency declaration.

“The question is when to pull the trigger,” a White House official said. The official described the move as “the best option” if no deal with Congress is attainable.

Within the president’s Republican Party, there appeared to be more concern in Congress than inside the White House about such a move.

“I don’t think that’s the way we should go,” said Sen. Lisa Murkowski (R., Alaska) as she walked into a meeting of Senate Republicans hoping to find a consensus among the GOP over how to end the impasse.

“At the end of the day, I want to solve the problem, and that’s going to require Congress to act,” said Sen. Thom Tillis, a Republican up for re-election in North Carolina in 2020, as he walked into Senate Majority Leader Mitch McConnell’s office Thursday morning for the GOP meeting. “The president’s got to make a decision within the law, and I’m sure it’ll be subjected to legal challenges,” Mr. Tillis said of declaring a national emergency.

—Rebecca Ballhaus and Alex Leary contributed to this article.

Write to Michael C. Bender at Mike.Bender@wsj.com, Kristina Peterson at kristina.peterson@wsj.com and Peter Nicholas at peter.nicholas@wsj.com