The holiday season burst of legislating has become standard in Congress, which seems to operate at its best when faced with crushing deadlines. But the December rush of bipartisan cooperation was particularly stunning given that it coincided with the House vote to impeach Mr. Trump for abuse of power and obstruction of Congress.

In a span of two weeks, the 116th Congress ended its first year with both the impeachment of the president for the third time in American history and final approval of thousands of pages and billions of dollars in complex legislation. The Senate on Tuesday approved a $738 billion military policy bill that would allow for the creation of the Space Force as the sixth branch of military and create paid parental leave for more than two million civilian federal workers. The legislation also carried several rebukes to countries that have provoked bipartisan anger on Capitol Hill, including China, Turkey and Russia.

As the upper chamber wrapped up debate and approval of a dozen judicial nominees, the House overwhelmingly passed a revision to Mr. Trump’s North American trade agreement, the product of months of negotiations between House Democrats and the administration.

And Mr. Trump on Thursday signed legislation that would permanently replenish $255 million a year to support science, technology, engineering and math in historically black colleges, tribal colleges and other higher education institutions over the next two years.

“The thing that makes them come together is the date,” said Representative Jan Schakowsky of Illinois and one of the key Democratic negotiators in crafting revisions to Mr. Trump’s trade deal. “We’re running out of time here.”

Proponents, particularly on the appropriations committees that control federal spending, were triumphant, having assured colleagues and reporters for weeks that it was indeed possible to resolve persisting issues in the dozen must-pass spending bills before the end of the month.

“I’m pleased that I was proven right,” said Senator Susan Collins, Republican of Maine, adding that she was particularly surprised that lawmakers were able to resolve negotiations over a series of tax credits and other breaks that were set to expire or had already ended.