Mr. Murtha, who put together the bill as the chairman of the House military appropriations subcommittee, defended the practice and lashed out at Mr. Flake.

Mr. Murtha said he had long sought earmarks as a way to create jobs in Pennsylvania. He said the state had sent a disproportionate number of soldiers to Iraq and Afghanistan compared with the level of military contracts it had typically received.

He said that he had an obligation to bring work to the small businesses in his area and that some of the earmarks, like $2.2 million for body-armor research, grew out of his visits with troops in Afghanistan and with wounded troops in hospitals.

“I’m not sure how often Mr. Flake goes to the hospital,” Mr. Murtha said.

Mr. Murtha, who was visibly angry, said several times that the bill included language instructing the Pentagon to seek competitive bids on the earmarked projects, and other lawmakers noted that Congress has the final say on spending decisions.

But Mr. Flake said that in the past, most companies that had sought the earmarks ended up with the contracts.

The overall bill, which would set military appropriations for 2010, passed by 400 to 30. The Senate will take up its version later this year, and the two bills will need to be reconciled in conference.

Mr. Obama had repeatedly threatened to veto any bill that included more money for the F-22, the world’s most advanced fighter, as the Pentagon seeks to shift more from high-tech weaponry to simpler systems the troops can use now.