The yearslong legal fight over former President Donald Trump's decision to divert billions of dollars to build a U.S.-Mexico border wall formally ended on Tuesday.

Wisconsin became the last of 20 states to drop out of the two lawsuits, which were rendered all but moot when President Joe Biden issued an executive order in 2021 that halted wall construction using up to $6.7 billion intended for National Guard units, military construction projects and police.

Wisconsin stood to lose $8 million that was supposed to cover a new National Guard firing range. The federal government has since restored the money for the firing range, according to the Wisconsin Legislature’s attorneys and the state Justice Department.

WISCONSIN DOJ TO SEEK LEGISLATIVE PERMISSION TO BOW OUT OF TRUMP-ERA BORDER WALL SUIT

The 9th Circuit U.S. Court of Appeals had ruled in favor of the states in October 2020, prompting the federal government to ask the U.S. Supreme Court to review the cases. After Biden’s executive order, the justices sent the cases back to a lower court.

Trump visits border wall

Then-President Donald Trump tours a section of the wall along the Mexican border, San Luis, Arizona, June 23, 2020. (AP Photo/Evan Vucci, File)

A federal judge in Oakland, California, dismissed the other states, including California, New York, Colorado, Hawaii and Minnesota, from the lawsuits on July 17.

DEMOCRATS SUE TO REINSTATE ABSENTEE DROP BOXES IN WISCONSIN

The Wisconsin Legislature's finance committee granted the state Justice Department permission to drop out of the lawsuit Tuesday. The Republican-controlled committee voted unanimously and without debate.

The state Justice Department made its formal request to exit the lawsuits on July 18, triggering Tuesday’s meeting.

CLICK HERE TO GET THE FOX NEWS APP

The department needed permission from legislators to get out of the cases because of a 2018 law that requires the agency to seek permission from the finance committee before settling lawsuits. Wisconsin Republicans passed the law to give themselves more oversight of Democratic Attorney General Josh Kaul's activities after he defeated his Republican predecessor in the November 2018 elections.