President Trump’s proposal to slash domestic spending in order to preserve the two biggest drains on the federal government — Social Security and Medicare — has set up a battle to determine who now controls the Republican Party’s ideology.

The outcome could map the course of major challenges to come, including a revision of the tax code, a huge increase in infrastructure spending and any effort to balance the budget.

Since the start of his insurgent campaign, Mr. Trump has opposed his party’s long-held positions on a range of policies, including free trade, how to deal with Russia and the future of government entitlement programs.