The bill had nearly fallen apart over controversy about how to keep out of the public eye photos showing the U.S. military abusing detainees in custody, The Hill reported.
Obama decided last month to keep the photos secret, and a federal court stayed an American Civil Liberties Union lawsuit to have them released.
Last week, The Hill said, the Senate approved a measure to keep the photos secret, but the House still must vote on it.
After signing the bill, Obama said in a statement, "I want to thank the members of Congress who put politics aside and stood up to support a bill that will provide for the safety of our troops and the American people."
Along with about $80 billion to pay for the wars until Sept. 30, the bill includes $7.7 billion to prepare for possible spread of the H1-N1 flu and $5 billion in new borrowing for the International Monetary Fund.
The bill also includes $1 billion for the "cash-for-clunkers" program for car buyers who trade older cars for more efficient ones
Notable deaths of 2014 [PHOTOS]