WASHINGTON — House Republican leaders suffered a surprising setback on Wednesday when the House rejected their version of a stopgap spending bill, leaving unclear how Congress will provide money to keep the government open after Sept. 30 and aid victims of a string of costly recent natural disasters.

The 230-to-195 vote came after fiscally conservative Republicans joined an overwhelming majority of Democrats in opposing the legislation. As it became clear that the bill was going down, a number of Republicans changed their votes from yes to no.

The unexpected outcome illustrated how the intense fiscal fights of recent months had transformed the politics of disaster relief, which in the past has typically been rushed out of Congress with strong backing from both parties. Democrats remained nearly united against the measure because they saw the amount of disaster assistance — $3.65 billion — as inadequate, and they objected to the Republicans’ insistence on offsetting some of the cost with cuts elsewhere.

The vote also showed the Republican leadership’s continuing struggle to corral the most conservative members of the caucus, as more than 40 Republicans rejected the measure because they did not believe it cut spending enough.