Three months after first questioning the citizenship status of almost 100,000 registered voters, the Texas secretary of state has agreed to end a review of the voter rolls for supposed noncitizens that was flawed from the start.

The deal was announced Friday as part of an agreement to settle three legal challenges brought by more than a dozen naturalized citizens and voting rights groups against the state. The groups alleged that the voter citizenship review, which was launched in late January, was unconstitutional and violated federal protections for voters of color.

Secretary of State David Whitley — who has yet to be confirmed by the Texas Senate amid the fallout over the review — agreed to scrap the lists of registered voters his office had sent to county voter registrars for examination. Whitley’s office will instruct local officials to take no further action on the names of people it had classified as “possible non-U.S citizens," and county officials will be charged with notifying voters who received letters demanding they prove their citizenship that their registrations are safe.

The state is also on the hook for $450,000 in costs and attorney fees for the plaintiffs' lawyers.

The federal judge overseeing the case still must approve the agreement, and the state will have five days after the judge dismisses the plaintiffs' legal claims to officially rescind the list. But the settlement amounts to a profound defeat for the state leaders who defended the review even though it had jeopardized the voting rights of tens of thousands of naturalized citizens.

"Today's agreement accomplishes our office's goal of maintaining an accurate list of qualified registered voters while eliminating the impact of any list maintenance activity on naturalized U.S. citizens," Whitley said in a statement Friday. "I will continue to work with all stakeholders in the election community to ensure this process is conducted in a manner that holds my office accountable and protects the voting rights of eligible Texans."

The original review had been mired in controversy since day one, largely because of the faulty methodology the state used to compile the list and the fanfare with which it was announced.

Top Republican leaders, including Gov. Greg Abbott and President Donald Trump, took to Twitter to falsely tout the list as proof of illegal registrations and voting in Texas. In reality, the secretary of state’s office matched the voter rolls with data it requested from the Texas Department of Public Safety for individuals who at some point in the last few years told the department they were not citizens when they obtained a driver’s license or ID card. But the review did not account for people who could’ve become naturalized citizens since then and weren’t required to update DPS.

The settlement does not prohibit the secretary of state from screening the state's massive voter registration database for possible noncitizens, but state officials agreed they would rework their methodology to only flag voters who provided DPS with documentation showing they were not citizens after they were registered to vote.

It's unclear how that will shrink the original list of voters whose citizenship was questioned. Officials agreed to provide the plaintiffs with that number as well as three more updates once the state begins compiling weekly lists to send out to county officials.

Those changes are expected to address the issues at the heart of the state's first botched attempt at reviewing the voter rolls, which unraveled within days of announcing the effort when state workers began quietly informing local election officials that thousands of the names on the list shouldn’t have been there. A top election official in the secretary of state’s office later acknowledged that his office had overstated the number of flagged voters by about 25,000 names because of the mistake. And local officials quickly noted they had been able to verify that hundreds of other individuals on the list were naturalized citizens.

“After months of litigation, the state has finally agreed to do what we’ve demanded from the start — a complete withdrawal of the flawed and discriminatory voter purge list, bringing this failed experiment in voter suppression to an end,” said Andre Segura, legal director for the American Civil Liberties Union of Texas, which represented plaintiffs in the case. “The right to vote is sacrosanct, and no eligible voter should have to worry about losing that right."

In court in February, lawyers for the plaintiffs in the three lawsuits zeroed in on state officials’ admissions that they knew naturalized citizens would be affected by the review. Despite those admissions and errors in the data, state officials continued to stand by the review as routine list maintenance and a good faith effort to maintain the integrity of the voter rolls. They also went as far as blaming individual county officials for acting too quickly to question voters on their lists, even though those local officials followed the state's instructions for reviewing the eligibility of those voters.

Under the settlement, the state agreed to provide local officials with new training materials. The plaintiffs and the state reached the settlement agreement two months after District Judge Fred Biery signaled his displeasure with the way Texas handled the review. In temporarily putting the effort on hold after three days of testimony in San Antonio, Biery chided state officials for putting “perfectly legal naturalized Americans” on a path to receiving “ham-handed and threatening” letters that demanded they prove their citizenship to avoid getting kicked off the rolls.

In a scathing four-page order, Biery wrote that the letters exemplified “the power of government to strike fear and anxiety to intimidate the least powerful among us.”

“No native born Americans were subjected to such treatment,” Biery said.

State attorneys indicated to Biery in late March that they had proposed a deal to end the litigation. Despite early reports of an agreement, it took several weeks to iron out a deal in which the plaintiffs agreed to rescind their legal claims against the state and their requests for documents. (The plaintiffs indicated in the settlement agreement that they are not conceding that the state's review efforts comply with federal law, leaving them room to take the state back to court if they're troubled by subsequent reviews.)

The debacle prompted a congressional inquiry as part of a larger investigation into voter suppression in various states. Congressional investigators have requested documents and communications related to the review. But the state so far has mostly denied those requests, only handing over documents that were already public.

It remains unclear what the settlement means for the registered voters whose names were referred to Attorney General Ken Paxton, who has the authority to prosecute claims of voter fraud. In announcing the original review, Whitley noted his office had immediately handed over the list of names to the attorney general. Since then, Paxton’s office has offered mixed messages on whether it has begun to criminally investigate voters.

On Friday, the groups and lawyers who sued the state celebrated the settlement but lamented the confusion and frustration the review effort caused.

“State officials have wasted hundreds of thousands of dollars and struck fear and confusion into thousands of voters in order to pursue their voter suppression agenda," said Beth Stevens, voting rights legal director with the Texas Civil Rights Project, which was also involved in the lawsuit. "We are glad that this particular effort was stopped in its tracks, and we will remain vigilant to ensure that not one single voter loses their right to vote due to the actions of state officials.”

Disclosure: The Texas Secretary of State has been a financial supporter of The Texas Tribune, a nonprofit, nonpartisan news organization that is funded in part by donations from members, foundations and corporate sponsors. Financial supporters play no role in the Tribune's journalism. Find a complete list of them here.