Fani T. Willis was barely three days into her new job as district attorney of Fulton County, Ga., when a potential case caught her attention.

A recording had emerged of Donald J. Trump, in his waning days as president, telling Brad Raffensperger, the Georgia secretary of state and a fellow Republican, that he wanted to “find” nearly 12,000 votes, or enough to reverse his narrow 2020 election loss there. The call fell squarely in Ms. Willis’s new jurisdiction, since Fulton County includes the State Capitol building in Atlanta where Mr. Raffensperger works.

Ms. Willis had inherited an office with a deep backlog of cases exacerbated by the pandemic, and had limited staff. But she knew almost immediately that she would investigate.

“When allegations come about — about anything that would hamper society’s ability to believe in fair elections, or if there is even conduct that rises to the level of suspicion, I don’t think that I have a choice,” Ms. Willis said in February 2021, shortly after announcing that she had opened a criminal inquiry into the matter.

Over the next two and a half years, what began as an examination of a single phone call became a sprawling investigation stretching across multiple counties and states and into the federal government. On Monday, Ms. Willis announced that a grand jury had indicted 19 people on 41 felony counts, including Mr. Trump and a number of his former top aides and allies, on charges that they had criminally conspired to overturn the results of the 2020 election in her state.

That the most expansive case against Mr. Trump and his associates would emerge from a local prosecutor’s office in the Deep South was never a given.

Her office faced frequent security concerns and threats as the investigation played out, many of them racist, leading Ms. Willis to have staff members outfitted with bulletproof vests.

There was a parade of legal challenges from witnesses reluctant to testify in her investigation — including from Senator Lindsey Graham and Mark Meadows, Mr. Trump’s former chief of staff — though most eventually did so after losing court battles.

Ms. Willis’s own political judgment became a sticking point when a judge berated her for headlining a fund-raiser for a Democrat rival of a state lawmaker who was one of the investigation’s potential targets.

Through it all, she made clear that she would not be deterred. When she and a lawyer for Gov. Brian Kemp, a Republican, got into a disagreement over the terms of Mr. Kemp providing testimony in her investigation, Ms. Willis wrote to the lawyer in an email: “You have taken my kindness as weakness,” adding, “Despite your disdain, this investigation continues and will not be derailed by anyone’s antics.”

While Ms. Willis has been depicted by Mr. Trump and his allies as a left-wing zealot, she is actually a centrist, law-and-order prosecutor. Only a few months before taking office, when she was facing a primary against her old boss, an anonymous flier circulated that superimposed a photograph of Ms. Willis standing next to Mr. Trump and branded her as a Republican.

Before becoming district attorney, she was best known for helping lead a high-profile case a decade ago against a group of educators in the Atlanta public school system who were involved in a widespread cheating scandal. Some attacked her for prosecuting teachers and other educators, but she retorted in a 2021 interview that she was sticking up for children.

“Y’all can put it in my obituary,” she said of the criticism.

From the start of the Trump investigation, Ms. Willis floated the possibility of bringing charges under the state’s version of the Racketeer Influenced and Corrupt Organizations Act, or RICO, as she had done in the cheating case. One of her early hires as an outside consultant, in March 2021, was John E. Floyd, who wrote a guidebook on such laws, published by the American Bar Association.

But the investigation was slow to develop. Today, Ms. Willis has about 10 people working on the case, including Mr. Floyd, out of a total work force of 370 people.

Finding a lead prosecutor for what would be one of the highest-profile cases in the state’s history was another hurdle. After several candidates turned her down, she enlisted an old friend, Nathan Wade, a defense lawyer and former municipal court judge whose small firm handled personal injury cases as well as criminal defense.

As the case heads toward trial, Ms. Willis’s office is prosecuting another sprawling racketeering case involving prominent local rappers accused of operating a criminal gang. That case has its own dramas slowing it down, including legal sparring over evidence of a goat sacrifice and jury selection that has already taken more than seven months.

“We’re not one-dimensional, right?” Ms. Willis told a local radio station recently, adding that her office could pursue the election investigation “while making sure that, as you see, the murder rate is dropping in Atlanta. We can walk and chew gum at the same time.”

By last summer, the Trump investigation took a critical turn on two fronts. A special grand jury was empaneled at Ms. Willis’s request. In Georgia, such juries cannot bring indictments, but can gather information for longer periods of time than regular grand juries can, giving them the ability to dig into complex issues.

At the same time, the House committee investigating the Jan. 6 attack on the U.S. Capitol began its public hearings, and its fact-gathering would be a valuable source of information for the Georgia investigators.

But Ms. Willis was soon found to have committed a misstep. In July 2022, the judge presiding over the case, Robert C.I. McBurney, barred her from pursuing charges against Burt Jones, a state lawmaker and Republican candidate for lieutenant governor in Georgia. Ms. Willis had headlined a recent fund-raiser for Mr. Jones’s Democratic rival.

“This scenario creates a plain — and actual and untenable — conflict,” the judge wrote in his decision, after noting during a hearing on the matter that “the optics are horrific.” By then, Mr. Jones, one of the 16 pro-Trump “alternate electors” in Georgia, had been told that he could face charges, along with the other fake electors. But any potential prosecution of Mr. Jones, who eventually won election as Georgia’s lieutenant governor, would have to be handled by another prosecutor.

The special grand jurors spent the second half of last year interviewing about 75 witnesses over seven months.

“We definitely started with the first phone call, the call to Secretary Raffensperger,” said Emily Kohrs, the forewoman of the special grand jury, in an interview in February.

From there, they heard evidence about how votes and voting machines were handled. They discussed the vote counting that took place at State Farm Arena in downtown Atlanta, and the false claims that Rudolph W. Giuliani, Mr. Trump’s former personal lawyer, and other Trump allies made about ballot fraud taking place there.

The jurors “talked a lot” about state legislative hearings that Mr. Giuliani spoke at in December 2020, spreading misinformation about the election, Ms. Kohrs said, “and then we talked some about events leading up to and immediately following the January phone call.”

They also heard evidence about Trump allies breaching the election system in a rural county south of Atlanta in hopes of finding evidence that the election had been rigged.

As the special grand jury’s work proceeded, Mr. Trump hired a high profile Atlanta lawyer, Drew Findling, who had represented rappers such as Cardi B, Gucci Mane and Migos.

Mr. Findling tried repeatedly to derail the investigation, an aggressive strategy that is not unusual among Mr. Trump’s growing retinue of lawyers. Complications proliferated as a number of witnesses wavered, and by May more than half of the bogus Trump electors were cooperating with Ms. Willis’s office.

Georgia judges also appeared to run out of patience with the Trump team’s filings. The State Supreme Court unanimously rebuffed Mr. Findling’s efforts to have Ms. Willis disqualified. And Judge McBurney, of Fulton County Superior Court, encouraged the Trump team to follow professional standards “before burdening other courts with unnecessary and unfounded legal filings.”

This week, after the charges were announced, Mr. Findling and Mr. Trump’s other Georgia lawyers, Jennifer Little and Marissa Goldberg, said in a statement that they “look forward to a detailed review of this indictment which is undoubtedly just as flawed and unconstitutional as this entire process has been.’”

With the indictment in the books, a new set of legal battles is now sure to begin. Ms. Willis has made clear that this is not an ordinary prosecution, going so far as to instruct many employees to work from home for the first half of August as charges loomed and security concerns built.

Yet she has also emphasized that in some ways, she will treat the case against Mr. Trump like any other.

If anyone interfered with the election, “I have a duty to investigate,” she said, adding: “In my mind, it’s not of much consequence what title they wore.”