TOPEKA, Kan. — Kansas Secretary of State Kris Kobach stepped aside from his duties as the state’s top elections official Friday until his hotly contested primary challenge to Gov. Jeff Colyer is resolved, but rejected Colyer’s accusations that the advice he has been giving local election officials on handling ballots violates state law.

Kobach said in a letter to Colyer that he was turning his election duties over to his top deputy. Colyer had demanded in his own letter Thursday to Kobach that the secretary of state stop providing guidance to county officials as they counted late mail-in ballots from Tuesday’s Republican governor’s race and prepared to count other ballots next week.

“Although I would discharge my duties ethically, impartially, and responsibly, I have carefully considered your request and have decided that it is in the best interest of the citizens of Kansas that I permit another to perform the duties of the secretary of state until the conclusion of the 2018 primary election process,” Kobach wrote.

Under state law, mail-in ballots are counted if they were postmarked Tuesday and arrive in county election offices by Friday. The secretary of state’s office was updating vote totals as it received new numbers from individual counties.

READ MORE: 8 key takeaways from Tuesday’s primaries

With 25 of the state’s 105 counties reporting, Kobach’s lead almost doubled to a still-tiny 241 votes out of more than 311,000 cast. It had been 121 votes after discrepancies were found between results reported by two counties and what Kobach’s office posted on its website.

Kobach is a conservative lightning rod who alienates even some fellow Republicans, but he is perhaps President Donald Trump’s closest political ally in Kansas and had Trump’s tweeted endorsement. Colyer, backed by the National Rifle Association and a strong abortion opponent, is trying to avoid becoming the first Kansas governor to lose a primary since 1956. The winner will face Democratic state Sen. Laura Kelly, of Topeka, in the November general election.

Colyer has accused Kobach of giving county election officials guidance “not consistent with Kansas law,” and said Friday on Fox News that he was worried that some mail-in ballots were not being counted as required.

In addition to counting mail-in ballots, county officials must review nearly 9,000 provisional ballots, given to voters at the polls when their eligibility is in question. The counties have until Aug. 20 to finish. Colyer’s campaign on Friday announced plans to have representatives in all 105 counties when provisional ballots are reviewed.

The secretary of state’s role in the actual counting of ballots is limited: His office provides guidance, compiles statewide vote tallies and provides general supervision.

Kobach is a conservative lightning rod who alienates even some fellow Republicans, but he is perhaps President Donald Trump’s closest political ally in Kansas and had Trump’s tweeted endorsement.

Kobach said he will hand over those duties to his top deputy, Assistant Secretary of State Eric Rucker. Kobach went even further than Colyer had demanded by saying that Rucker also will serve on the three-member state board that will certify the primary’s final results by Aug. 31. Colyer is also a member of that board, and Kobach called on him to let Lt. Gov. Tracey Mann serve on the board instead.

Kobach also flatly rejected Colyer’s criticisms of the secretary of state’s actions to date.

“As governor of Kansas, your unrestrained rhetoric has the potential to undermine the public’s confidence in the election process,” Kobach wrote.

Kobach is a vocal advocate of tough voter identification laws and served as vice chairman of Trump’s now-disbanded election fraud commission. He publicly backed Trump’s unsubstantiated claims that several million illegal ballots may have been cast in the 2016 election, costing Trump the popular vote.

States vary considerably in who has authority over elections. In most, either an elected secretary of state is the chief election official or a lieutenant governor has those duties, according to the National Conference of State Legislatures.

In Georgia, Secretary of State Kemp, now the GOP nominee for governor, has faced calls by state Democrats to step down from his position, which oversees elections as well as professional licensing and business registrations.

Common Cause Georgia, the state chapter of a national ethics watchdog group, has also joined the call, noting that Republican Karen Handel, the last secretary of state to run for governor, stepped down as soon as she qualified as a candidate. Common Cause advocates that secretaries of state be a nonpartisan position.

A spokesman said Friday that Kemp had no plans to resign.

And in Kentucky in 2014, Secretary of State Alison Lundergan Grimes, a Democrat, stayed in office while she ran for U.S. Senate, challenging longtime Republican Sen. Mitch McConnell. Although she did not face calls to step down, McConnell used the fact that she was drawing a state paycheck as a line of attack.

Associated Press writers Christina Almeida Cassidy and Benjamin Nadler also contributed from Atlanta.