WASHINGTON – A bipartisan group of House members announced a deal Thursday on sweeping immigration legislation, a breakthrough that could boost chances for one of President Obama’s top second-term priorities.

It came after months of secretive talks among the four Republican and four Democratic House members had seemed to stall in recent days even as an immigration bill in the Senate moved forward. The House members met for two hours Thursday evening, emerging to announce that they had a deal.

“We have an agreement in principle. We’re now going to work on finishing up the drafting of the bill,” said Rep. John R. Carter, R-Texas, a leader of the group.

Rep. Luis V. Gutiérrez, D-Ill., another member, said over Twitter: “Important breakthrough, some details still to be worked out, but very pleased things are moving forward.”

Carter and others declined to give details, saying they had agreed among themselves not to do so.

Group members had been saying for months that they were near a deal, but in recent days, talks appeared close to breaking down over a few unresolved details. These included a new visa program for lower-skilled workers, and how to handle health care coverage for immigrants in the country illegally who would gain legal status under the bill.

Lawmakers and aides suggested earlier Thursday that one option would be for the group to release a bipartisan bill that simply left those issues out, allowing Republicans and Democrats in the group to offer their own plans on those aspects of the legislation.

Meanwhile, members of the group were under pressure to deliver from other lawmakers and outside advocates who feared that they would lose their window to have a voice in the debate if they didn’t produce something soon. A bill released last month by leading senators is moving toward a vote in the Senate Judiciary Committee and has become the focus of the immigration debate.

“I am concerned that the bipartisan group has been unable to wrap up their work,” House Speaker John A. Boehner, R-Ohio, told reporters earlier Thursday, before the group announced its deal. “And I know that there are some very difficult issues that have come up. But I continue to believe that the House needs to deal with this, and the House needs to work its will. How we get there, we’re still dealing with it.”

The House group had struggled to come up with a plan that could have a possibility of passing the Republican-controlled House while also satisfying Democrats in the group. They have discussed a path to citizenship that would take 15 years for the estimated 11 million people living here illegally, two years longer than contemplated by the Senate bill, which is backed by Obama.

Overall, the legislation would share the same goals as the Senate plan: boosting border security, an increased focus on workplace enforcement, new means to allow workers to enter this country legally, and the eventual prospect of citizenship for millions.

As the House group bogged down, House Judiciary Committee Chairman Robert W. Goodlatte, R-Va., separately has moved forward with individual, narrowly focused bills on immigration, including one on workplace enforcement that was discussed at a hearing Thursday.

The Senate Judiciary Committee held its third work session Thursday to plow through some 300 amendments to the Senate immigration legislation. The committee voted down an amendment by Sen. Charles E. Grassley, R-Iowa, that would have required the implementation of an electronic employer ID verification system in 18 months, instead of the four years contemplated by the bill.