WASHINGTON — Republicans are moving toward passing a two-week stopgap measure to avoid a looming government shutdown, but the path in the coming weeks is treacherous, with obstacles on both sides of the aisle as lawmakers push their own priorities, some unrelated to government spending.

With government funding set to expire at the end of Friday, Republicans are aiming to buy more time so they can negotiate over a long-term spending package. The task is complicated by a feud between President Trump and Democrats, whose votes Republicans need to secure passage, and measures on the politically fraught issues of immigration and the Affordable Care Act.

The possibility of a shutdown looms just after Senate Republicans succeeded in passing their sweeping tax overhaul, a moment of triumph for a party that has struggled to produce big achievements despite controlling Congress and the White House. But promises made to secure passage of the tax bill could further complicate negotiations on government funding, and any failure at the fundamental task of keeping the government running would swiftly undercut Republicans’ display of progress.

The threat of a shutdown escalated last week after President Trump fired off a Twitter post attacking the top Democrats in Congress, who in turn pulled out of a planned White House meeting, deepening the rift between the parties at a time when they are already at odds over issues like taxes, health care and immigration.