The US Senate has passed a crucial funding bill that could bring the longest government shutdown in history to an end within days.

The bill passed in a 60-40 vote late on Monday, with nearly all Republicans joining eight Democrats who splintered from the party to approve it. The deal funds the government until the end of January.

The House of Representatives will now have to pass the bill before President Donald Trump can sign it into effect. Trump signalled he would be willing to do so earlier on Monday.

The deal came to fruition over the weekend, after some Democrats joined Republicans and negotiated an agreement to get federal employees back to work and essential services restarted.

Republicans - who hold a 53-47 majority in the Senate - needed the measure to clear the 60-vote minimum threshold.

Democratic Senators Dick Durbin, John Fetterman, Catherine Cortez Masto, Maggie Hassan, Tim Kaine, Jackie Rosen, and Jeanne Shaheen broke from the rest of their party to vote in favour of the funding bill.

They were joined by Maine's Angus King, an independent who caucuses with the Democrats, who also voted to reopen the government.

Only one Senate Republican - Kentucky's Rand Paul - voted with the majority of Democrats against it.

The announcement of the bill's passage was made to a largely empty room, but the senators who stayed until the end cheered and applauded.

We are going to reopen government, we are going to ensure that federal employees... will now receive compensation that they're earned and deserve, Senator Susan Collins, a Republican who played a key role in authoring the bill, said after it passed.

Many government services have been suspended since October, and around 1.4 million federal employees are on unpaid leave or working without pay.

The shutdown has had wide-ranging impacts on various services, including US air travel and food benefits for 41 million low-income Americans.

On Monday, more than 2,400 flights across the US were cancelled according to airline traffic tracker FlightAware. At least 9,000 were delayed.

The funding bill will now go to the Republican-controlled House of Representatives, where members have been out of session and away from Washington since mid-September.

On Monday, with the Senate deal seemingly in reach, House Speaker Mike Johnson called members of his chamber back to Washington.

The House will begin discussing the measure on Wednesday, although it is unclear exactly how much time that process may take.

Republicans have a two-seat majority in the House so every vote will count.