(CNN) — Negotiators are closing in on a spending deal to keep the rest of the government funded through the fiscal year, two sources familiar told CNN, but lawmakers still face hurdles to pass legislation and avert a shutdown for major agencies this weekend.

Congressional negotiators reached an agreement Monday on funding for the Department of Homeland Security, according to a GOP leadership aide. At a time when security at the southern border has become a central issue in the 2024 campaign, funding for the agency had become a major obstacle.

Aides caution that while there is a broad agreement on many of the elements of the bills as of Monday night, there is still work left to write the legislation. That process can be time consuming.

The hope is for text to be released in the next few days.

That means that lawmakers are still facing an enormous time crunch to pass the legislation ahead of the Friday night deadline. House Republicans are operating under a three day rule, which means lawmakers need several days to review the text before they can vote. There is also expected to be considerable blowback from Mike Johnson’s right flank that the speaker will have to navigate.

Forty-three members of the House Freedom Caucus have already called on House Republicans to reject any deal without key border provisions.

After months of averting shutdowns at the eleventh hour with stopgap bills, Congress finally passed a package of six bills in early March to fund a slate of government agencies for the rest of the fiscal year – but the work isn’t over yet.

A number of key government operations still need to be funded by the end of the day on Friday, March 22, including the departments of Defense, Homeland Security, Labor, Health and Human Services, Education, State, and the legislative branch.

The current fiscal year began more than five months ago on October 1, 2023. Since then, lawmakers have faced a series of fiscal cliffs as a result of funding deadlines created by short-term extensions.

There are a number of challenges ahead.

Under House GOP rules, leadership needs 72 hours for their members to review bill text. That means lawmakers could be working through the weekend to pass the bills after the Friday deadline has already lapsed. Then, it would need consent of all 100 senators to quickly schedule a vote – something that can be extremely difficult, especially over funding legislation.

While government operations would halt if funding is not approved by the deadline, the damage would be minimal if a shutdown is only relegated to the weekend.

Two sources familiar with talks say that negotiators were prepared to move ahead over the weekend with a one-year stopgap measure to fund DHS, but the White House got involved late to try and push for a full-year spending bill. That has slowed down the talks, the sources said.

This DHS funding bill is always one of the most complicated to get across the finish line. Aides say work to fund other agencies including State, Education and Labor, HHS, Treasury and Defense are largely closed out.

In the House, Johnson must navigate an extremely narrow majority and pushback from his right flank. Hardline conservatives have expressed anger over Johnson’s handling of the government spending fight – and the speaker needed to rely on both Republican and Democratic votes to pass the six-bill funding package earlier this month.

That package, which was signed into law by President Joe Biden, included funding for the departments of Agriculture, Commerce, Justice, Veterans Affairs, Energy, Interior, Transportation, Housing and Urban Development, as well as the Food and Drug Administration, military construction and other federal programs.

Johnson was elected speaker last year after conservatives forced former Speaker Kevin McCarthy from his leadership post, raising questions over whether Johnson could face a similar threat to his speakership amid backlash from the far-right wing of his conference.

McCarthy’s historic and unprecedented ouster plunged House Republicans into a weeks-long period of intense turmoil as they struggled to elect a successor, and many Republicans do not want to see that scenario play out a second time.

(Copyright (c) 2024 CNN. All Rights Reserved. This material may not be published, broadcast, rewritten, or redistributed.)

Join our Newsletter for the latest news right to your inbox