WASHINGTON — The U.S. House of Representatives voted along mostly partisan lines Tuesday to send an additional $26.1 billion in Medicaid and education funding to cash-strapped states.

Soon after, President Barack Obama signed into law this measure that contains $16.1 billion in enhanced federal assistance for the health care program and $10 billion for preserving jobs of elementary and secondary school teachers.

For Washington, it means an estimated $338 million for Medicaid programs, a large enough sum to cover the state’s looming budget deficit and avert the need for an emergency session of the Legislature.

Lawmakers in this state counted on those dollars when they approved a budget earlier this year. Without them, the state faced a shortfall of slightly more than $300 million.

The federal bill also will bring about $205 million in education funding, which will help cover salaries of about 3,000 teachers. That money had not been counted upon for the balancing of the budget.

Democratic Reps. Jay Inslee and Rick Larsen, who represent Snohomish County, voted for the bill, which passed by a 247-161 margin.

“We’re going to have almost 3,000 teachers laid off (in Washington) if we don’t pass this bill,” Inslee said