WASHINGTON — The Senate passed a $162 billion war spending plan Thursday, sending to President Bush legislation that will pay for operations in Iraq and Afghanistan until the next president takes office.

The bill, approved 92-6, includes a historic boost in college aid for troops, plus a 13-week extension of unemployment benefits and $2.7 billion in emergency flood relief for the Midwest.

The Senate, however, narrowly failed to approve a House-passed bill to cancel a scheduled cut in payments to doctors who treat Medicare patients.

It also failed to resolve differences over home mortgage legislation and the administration's electronic surveillance program. Those matters will await lawmakers when they return from a 10-day July break.

The spending bill will bring to more than $650 billion the amount Congress has provided for the Iraq war since it started more than five years ago. For operations in Afghanistan, the total is nearly $200 billion, according to congressional officials.

Last week, the House approved the war funding measure, 268-155. The domestic add-ons were approved separately by a 416-12 vote. The White House has said it supports the combined measure, which technically allowed the measure to advance without senators having to vote specifically for the war funding, a distasteful matter for many Democrats.