WASHINGTON—Congress passed legislation to renew funding for highways, freeze the interest rate on government-backed student loans and extend federal flood insurance.

With three popular programs under threat in an election year, Democrats and Republicans in both chambers worked together Friday to meet July deadlines. President Barack Obama signed the package of legislation into law Friday.

"There...