A majority of lawmakers favored the idea but not by a big enough margin, and President Bush has promised a veto.