Maryland lawmakers grilled leaders of the Motor Vehicle Administration and the State Board of Elections on Thursday over what the officials said was as “an inadvertent programming error” that potentially affected nearly 72,000 residents who attempted to register to vote in the June 26 primary.

Christine Nizer, head of the MVA, described an error-riddled process that began with a programming mistake made by a contract employee in April 2017 and culminated with officials’ announcement on the eve of the election that as many as 80,000 voters — nearly quadruple the amount estimated days before — were affected by the error and would have to file provisional ballots.

“I am personally sorry,” said Nizer, who testified before lawmakers in a joint committee hearing in Annapolis. “Clearly, we failed in this case.”

Because of the programming error, the MVA did not send voter registration information to the State Board of Elections for thousands of people who completed a change of address at an MVA kiosk, then chose to register to vote but did not purchase a driver’s license, identification card or vehicle registration.

Nizer said that after removing duplicate records and unaffiliated voters who had no ballot to vote on in the primary, the estimated number of people affected dropped to 71,981.

Of the individuals potentially affected by the error, 3,538 cast provisional ballots and 5,163 cast regular ballots, according to Nizer — which lawmakers pointed out meant that approximately 80 percent of those potentially affected did not cast votes.

State Elections Administrator Linda H. Lamone said “yes” when asked by lawmakers whether she was worried about the error having a deterrent effect on voters. She said the state board had not asked local boards for reports on whether voters were turned away because of the error.

Del. Alonzo T. Washington (D-Prince George’s) said he knew of three people who had recently changed their address and were told they could not cast votes June 26.

Nizer said that the program has been fixed and that the MVA is conducting weekly internal audits to ensure that all voter registration information is sent to the elections board. Gov. Larry Hogan (R) has also directed the auditor for the state Transportation Department to conduct a review and ordered leadership to participate in legislative hearings.

“We have to learn from this experience, and we know that,” Nizer said.

Sen. Joan Carter Conway (D-Baltimore City), chairwoman of the Senate Education, Health and Environment Committee, and Del. Anne R. Kaiser (D-Montgomery County), chairwoman of the House Ways and Means Committee, held the joint hearing.

Conway decried the episode as “trampling on the constitutional rights of individuals to vote” and said she was “totally appalled” by how the MVA handled it.

Some lawmakers assigned blame to the Hogan administration, whose transportation secretary appointed Nizer in 2015.

State Sen. Ronald N. Young (D-Frederick) called the MVA “one of the most mismanaged” agencies he has seen and said Hogan’s administration had not been “that transparent’’ about the mistake. He and several other lawmakers pointed out that Hogan — who is usually active on social media — barely posted about the error, even as the State Board of Elections and advocacy groups launched a campaign to notify affected voters that they could still vote via provisional ballot.

Hogan spokeswoman Amelia Chasse said “the governor made numerous public statements about this in the press, and consistently urged all impacted Marylanders to exercise their right to vote.”

Nizer said she had seen “absolutely nothing” to indicate that the contractor’s actions were politically motivated.

All provisional ballots are counted in Maryland, even if they do not change the outcome of the election, according to the State Board of Elections. But law­makers and Nizer acknowledged that some voters may be less inclined to vote if they know they are casting provisional ballots — which are not counted on Election Day — because of the perception that they are less important.

There were 20,563 provisional ballots cast this year — up from 14,496 in the 2014 gubernatorial primary — an increase that could have been partly driven the number of provisional ballots cast because of the MVA error.

Officials began counting provisional ballots on the second Wednesday after the election. In several close races this year, results have been delayed as provisional and absentee ballots are counted.

In Montgomery County, longtime County Council member Marc Elrich was declared the winner of the Democratic primary for county executive late Sunday after winning 80 more votes than Potomac businessman David Blair after provisional and absentee ballots were counted.

A recount is underway in the county executive race in Baltimore County after former state delegate Johnny Olszewski Jr. got nine more votes than state Sen. Jim Brochin in the Democratic primary.

Kaiser said the local election boards did “an awesome job” of handling “the influx of provisional ballots” they received.

What matters is ensuring the problem is fixed ahead of the general election, she said, pointing out there are only 71 days until the first round of absentee ballots are mailed overseas.