(Recasts with negotiators completing legislation)
By Richard Cowan and Steve Holland
WASHINGTON, Feb 13 (Reuters) - U.S. lawmakers late on Wednesday completed writing a border security bill that was expected to deny President Donald Trump's request for $5.7 billion to help build a wall on the U.S.-Mexico border, with the Senate and House of Representatives expected to vote on the bill Thursday.
A House Democratic aide said the final draft of the legislation was circulating among a group of 17 negotiators and was expected to be made public soon.
The aide added that the Senate would first vote on the bill sometime on Thursday. If it passes there, the House would then vote on final approval that evening, which would clear it for signing into law by Trump by a Friday deadline.
Without the legislation, about one-quarter of federal government agencies would be forced into a partial shutdown for lack of operating funds.
Trump has not yet said that he would embrace the measure but on Wednesday appeared to be edging toward backing the deal once he saw final details.
Trump, widely blamed for a five-week shutdown that ended in January, said he did not want to see federal agencies close again because of fighting over funds for the wall, one of his signature campaign promises in the 2016 election.
The Republican president did not commit himself to backing the government funding agreement struck between Democratic and Republican lawmakers this week. But two sources and a Republican senator close to the White House said he would likely sign off on it.
"I don't want to see a shutdown. A shutdown would be a terrible thing. I think a point was made with the last shutdown," Trump told reporters. "People realized how bad the border is, how unsafe the border is, and I think a lot of good points were made."
Republican Senator Lindsey Graham said Trump was "inclined to take the deal and move on."
Graham told reporters that Trump would then look elsewhere to find more money to build a wall along the U.S. southern border and was "very inclined" to declare a national emergency to secure the funds.
With a Friday night deadline looming before a shutdown, there is little time for the White House and the political parties in Congress to agree on funding.
Funding is due to expire for the Department of Homeland Security, the Justice Department and several other federal agencies.
LESS MONEY
The outline of a congressional agreement reached on Monday falls far short of giving Trump all the money he wants to help build the wall. Instead, congressional sources say, it includes $1.37 billion for new barriers - about the same as last year - along 55 miles (90 km) of the border.