The House vote was a defeat for Speaker John A. Boehner (R-Ohio), who was again unable to bring unruly conservatives in line in the debate over President Obama’s immigration actions. (Jim Lo Scalzo/European Pressphoto Agency)

House Speaker John A. Boehner surrendered Tuesday to Democratic demands to fully fund the Department of Homeland Security, ending a tense three-month showdown over immigration. But the move could further strain relations between the speaker and hard-line conservatives, whose growing dissent threatens the future of the unified Republican majority.

After refusing to do so for weeks, Boehner (R-Ohio) cleared the way for the House to vote on a bill replenishing DHS funds through September. The legislation passed 257 to 167, with the support of all Democrats who voted but just 75 Republicans, less than a third of the caucus. President Obama was expected to sign it swiftly.

The outcome, which averted a DHS shutdown, was a major victory for Democrats, who stood firm against Republican attempts to use the debate to fight Obama’s executive actions on immigration. It was a blow to Boehner, who was unable to control unruly members of his caucus and gained no concessions on immigration. He backed down after concluding that the fight could not be won through legislation.

The past week’s convulsions also call into question the GOP leadership’s ability to deal with other important deadlines ahead. The deadline to fix a Medicare reimbursement rate for doctors comes at the end of this month, and funding for federal highway programs expires in May. On top of that, House and Senate Republicans must agree on a budget resolution this spring or the threat of a broader federal government shutdown will increase in the fall.

Throughout it all, they need to find a way to deal with rogue House conservatives who are itching to challenge Obama’s agenda.

“They’ve got to pick a couple of fights with Obama that they can win,” said former speaker Newt Gingrich (R-Ga.), who faced a similar intraparty revolt in the 1990s.

In a meeting with rank-and-file Republicans on Tuesday morning, Boehner explained his decision to hold the vote, angering some conservative lawmakers bent on keeping up the battle against Obama’s directives, which would protect millions of undocumented immigrants from being deported.

“As you’ve heard me say a number of times, the House has done its job by passing legislation to fund DHS and block the president’s executive actions on immigration,” Boehner said in the meeting, according to a person in the room. “Unfortunately, the fight was never won in the other chamber.”

Boehner was referring to the Senate, where a House-passed bill that would have funded DHS but held back money for Obama’s immigration actions failed to gain traction as Democrats repeatedly blocked it.

The person in the meeting, who spoke on the condition of anonymity to discuss internal strategy, said Boehner presented Republicans with three options: take up a Senate funding bill with no immigration riders, try to pass a new stopgap measure or brace for a DHS shutdown.

He told them he was going with the Senate bill. He also pointed to the judicial battle over Obama’s immigration actions as a sign that the confrontation is not over.

But that didn’t please everyone.

“I think we are going to be much more willing to judge our leadership by their actions than their words going forward,” said Rep. Mick Mulvaney (R-S.C.), who voted against the bill and was disappointed that GOP leaders didn’t fight harder on immigration.

Mulvaney, along with 51 other Republicans, voted against a three-week stopgap bill Friday, handing Boehner an embarrassing defeat as he sought to buy more time in the debate. After that, congressional leaders scrambled to pass a seven-day bill to avoid a DHS shutdown.

The opposition Boehner faces is led by the Freedom Caucus, a small group of conservatives who have frequently clashed with the speaker. While members of the group, including Mulvaney, said they would not move to depose Boehner as speaker, they suggested that they would not roll over for party leaders when they disagreed with them.

“There are more battles coming,” said Rep. John Fleming (R-La.), a Freedom Caucus member.

The Republican discord was also fueled Tuesday from outside the halls of Congress. The American Action Network, a nonprofit supportive of GOP leadership, launched an ad campaign aimed at pressuring Mulvaney and others to fund DHS.

Boehner and his top deputies tried to avoid drawing attention to their DHS strategy Tuesday. They scuttled plans for a news conference after the morning meeting, and they announced their intentions on the same day Israeli Prime Minister Benjamin Netanyahu addressed a joint meeting of Congress.

But Democrats were happy to trumpet the news. Even after losing their Senate majority and becoming a smaller minority in the House in November’s midterm elections, they have demonstrated that they can exert influence by uniting against the Republicans.

“We’re very proud of the vote that happened today,” said House Minority Leader Nancy Pelosi (D-Calif.).

Boehner’s allies argued that he would not suffer politically because of the protracted DHS fight, pointing to a fractured resistance and what they cast as a principled decision.

“Passing the Homeland Security appropriations bill is the right thing to do. I believe that the speaker will be just fine,” said Rep. Charlie Dent (Pa.), a moderate Republican who voted for the bill.

Rep. Tom Cole (R-Okla.), another Boehner supporter, said that when he reviewed the list of 52 Republicans who defected last week, he didn’t see a coherent group capable of derailing the speaker’s agenda. Rather, he saw some who were “irreconcilable,” others who were “misled” and a third batch looking to avoid conservative primary challengers.

“Other than being mad just for being mad, show me why the route you are proposing can work,” he said, referring to the defectors.

The DHS debate also opened a divide between House and Senate GOP leaders, as well as between rank-and-file Republicans in the two chambers. Last week, Boehner told his caucus members that he had not spoken with Senate Majority Leader Mitch McConnell (R-Ky.) in two weeks.

Sen. Charles E. Schumer (D-N.Y.) told reporters he was “pleased” that House Republicans cleared the way for the DHS bill, but he added that new showdowns pushed by House conservatives could endanger upcoming talks on a highway bill, the debt ceiling and government funding for the next fiscal year.

“I also shudder for the future of this Congress,” Schumer said.

Democrats argued for weeks that Republicans were putting the country’s safety at risk. The Democratic Congressional Campaign Committee launched robo-calls Tuesday against Republican lawmakers, warning against “playing games with our national security.”

At DHS, there was relief that the agency would not face the prospect of a shutdown before the end of the fiscal year.

“Now our men and women can return to the vital work of combatting terrorism, ensuring border security, port security, aviation security, cybersecurity, and our other vital homeland security missions, without the uncertainty of a furlough or a delayed paycheck hanging over their heads,” Homeland Security Secretary Jeh Johnson said in a statement.

Many lawmakers echoed that sentiment at the end of a grueling political battle that started in December during a larger fight over funding the rest of the government.

“Better late than never,” said Rep. Nita M. Lowey (D-N.Y.). “Glad we passed this bill today.”

Paul Kane and Mike DeBonis contributed to this report.