House of Representatives Speaker Nancy Pelosi delivers remarks at the opening plenary session of the National Association of the Advancement for Colored People's annual convention in Detroit, July 22, 2019.

The House passed a bill Thursday to fund the government for two months and avoid another shutdown.

The Democratic-held chamber approved the measure to keep the government running through Nov. 21 by a 301-123 margin. It now heads to the Senate, where Majority Leader Mitch McConnell, R-Ky., has signaled he will back a temporary spending plan.

Congress has until Sept. 30 to pass a funding bill and prevent a funding lapse. A shutdown would come only months after a partial government work stoppage in December and January that lasted a record 35 days.

Last month, lawmakers approved a two-year deal to set budget levels, suspend the U.S. debt ceiling and dodge automatic, across-the-board spending cuts. However, passing the appropriations bills to actually allocate the money to specific agencies has proven harder to do before the shutdown deadline.

So Congress decided to pass a so-called continuing resolution to extend funding at current levels and keep the government running through most of November. Democrats and Republicans will now have to come to agreement on long-term spending bills amid yet another dispute over border security and military funding.

On Wednesday, Senate Democrats blocked GOP efforts to move forward with spending bills for the Defense Department and other agencies. The party argues Republicans have neglected key domestic programs and military funding by yielding to Trump's demands for more funding for barriers on the U.S.-Mexico border.

Senate Appropriations Committee Chairman Sen. Richard Shelby, R-Ala., accused the party of playing "partisan politics." ﻿

Subscribe to CNBC on YouTube.