WASHINGTON  After its first secret session in a quarter-century, the House on Friday rejected retroactive immunity for the phone companies that took part in the National Security Agency’s warrantless eavesdropping program after the Sept. 11 attacks, and it voted to place greater restrictions on the government’s wiretapping powers.

The decision, by a largely party-line vote of 213 to 197, is one of the few times when Democrats have been willing to buck up against the White House on a national security issue. It also ensures that the months-long battle over the government’s wiretapping powers will drag on for at least a few more weeks and possibly much longer.

With President Bush and Democratic leaders squaring off almost daily on the wiretapping question, neither side has shown much inclination to budge. The question now moves to the Senate, where lawmakers passed a bill last month that was much more to the liking of the White House. Unlike the bill approved Friday by the House, it would give legal immunity to the phone providers that helped in the National Security Agency’s wiretapping program, which President Bush says is essential to protect national security.

The House bill approved Friday includes three key elements: it would refuse retroactive immunity to the phone companies, providing special authority instead for the courts to decide the liability issue; it would add additional judicial restrictions on the government’s wiretapping powers while plugging certain loopholes in foreign coverage; and it would create a Congressional commission to investigate the N.S.A. program.