A former federal prosecutor, Mr. Bragg will take over an office that has brought charges against the family business of former president Donald J. Trump.Alvin Bragg was elected Manhattan district attorney on Tuesday and will become the first Black person to lead the influential office, which handles tens of thousands of cases a year and is conducting a high-profile investigation into former President Donald J. Trump and his family business.Mr. Bragg, 48, a former federal prosecutor who campaigned on a pledge to balance public safety with fairness for all defendants, beat out seven other Democrats for the nomination earlier this year and will succeed Cyrus R. Vance Jr., a Democrat who did not seek re-election. Mr. Bragg had been heavily favored to prevail over his Republican opponent, Thomas Kenniff, given that Democrats vastly outnumber Republicans in the borough.He will take over an office that continues to disproportionately prosecute Black defendants, and Mr. Bragg throughout his campaign has drawn on his personal experiences growing up in New York to illustrate the types of changes he wishes to make. Mr. Bragg has said he would show leniency to defendants who commit low-level crimes and has emphasized the importance of accountability for the police and the office’s prosecutors.Mr. Bragg will be working in close partnership with a police department run by Eric Adams, who won the race for mayor on Tuesday night. Mr. Adams and Mr. Bragg have some policy disagreements — Mr. Adams, a former police officer, has called for the restoration of the department’s plainclothes anti-crime unit, which Mr. Bragg opposes.In an interview earlier on Tuesday, Mr. Bragg pointed toward experiences that he said would inform his work and set him apart from his predecessors.“Having been stopped by the police,” he said. “Having a homicide victim on my doorstep. Having had a loved one return from incarceration and live with me.”Mr. Bragg’s election follows that of like-minded prosecutors around the country. His experience in law enforcement separates him from some of his peers in what has come to be known as the progressive prosecutor movement, including Larry Krasner in Philadelphia and Chesa Boudin in San Francisco. But Mr. Bragg’s policy positions are largely in line with others who have won office over the past decade, including Rachael Rollins in Boston and Kim Foxx in Chicago.His victory comes as Democrats are seeking to balance sweeping changes to the criminal justice system with some voters’ concern about rising gun crime. In 2020, millions of people around the country took to the streets to protest the police killings of George Floyd and Breonna Taylor and called for change. But after rises in homicides and shootings in New York and other cities, voters have expressed fears about public safety.Those fears may have influenced two prosecutorial races in Long Island, the results of which were far less decisive on Tuesday night. In Nassau County, with about 13 percent of the vote counted, the Republican candidate, Anne Donnelly, was leading her opponent Todd Kaminsky, a Democratic state senator, 51 to 49 percent.In Suffolk County, the Republican challenger, Ray Tierney, was leading the incumbent district attorney, Timothy Sini, 54 percent to 46 percent with about 31 percent of the vote accounted for.But Mr. Bragg won handily, and The Associated Press called the race for him just before 9:30 p.m. on Tuesday. Mr. Bragg held a commanding 68-point lead late Tuesday night with more than half of precincts reporting.At an election night party at Harlem Tavern, a crowd roared its approval when he arrived several minutes after the race was called.“We have been given a profound trust tonight,” Mr. Bragg said. “The fundamental role of the district attorney is to guarantee both fairness and safety.”He said that under his administration the racial disparities in the criminal justice system would be “shut down”; the trauma of sexual assault survivors would be a central focus; and those suffering from mental health issues would not be prosecuted.“The Day 1 job is guns,” Mr. Bragg said, mentioning shootings that had occurred nearby in the last several weeks. He said he planned to address the problem with “new tools,” not with the tools of the past.Mr. Bragg said getting people out of jail was another urgent priority, making tacit reference to what he called “a humanitarian crisis” on Rikers Island.On Twitter on Tuesday night, Mr. Kenniff congratulated Mr. Bragg.“While we may have competing visions on the role of D.A.,” Mr. Kenniff wrote, “we are aligned in our commitment to public safety and a fair criminal justice system.”Thomas Kenniff, who spent election night at the Metropolitan Republican Club on the Upper East Side, congratulated Mr. Bragg on Twitter.Andrew Seng for The New York TimesBy far the most high-profile case confronting Mr. Bragg is the investigation into Mr. Trump and his family business. Over the summer, the business and one of its top executives were charged with running a yearslong tax scheme that helped executives evade taxes while compensating them with off-the-books benefits.Mr. Vance’s investigation into Mr. Trump and his business is ongoing; Mr. Bragg has faced questions about it throughout his campaign and will continue to do so. Though he cited his experience of having sued the former president over 100 times while at the state attorney general’s office, Mr. Bragg has said he will follow the facts when it comes to the current inquiry.A lifelong resident of Harlem, Mr. Bragg began running for district attorney more than two years ago and slowly accumulated support from local political clubs and unions, and from figures including Representative Jerrold L. Nadler and Preet Bharara, the former U.S. attorney for the Southern District who hired Mr. Bragg as a federal prosecutor in Manhattan.In the primary he was flanked on his left by three candidates who argued against electing anyone with prosecutorial experience. Still, he was able to win important endorsements from progressives like Zephyr Teachout after releasing detailed plans about his vision for a new sex crimes unit and an expansion of the bureaus that oversee economic crimes. He beat out another former federal prosecutor, Tali Farhadian Weinstein, for the nomination, in a close race that came to focus more on public safety as gun crime rose.A sign of Mr. Bragg’s success at unifying Democrats came on Saturday when two other Democrats who ran in the primary, Eliza Orlins and Liz Crotty, showed up at a campaign stop in Union Square to lend him their support.Ms. Orlins was among the candidates who had argued that no one with prosecutorial experience should hold the job, while Ms. Crotty emphasized the need for public safety from the start of the race and won endorsements from several police unions.In interviews, both said that while they disagreed with Mr. Bragg on certain points, they trusted him to do the right thing.“He’s had experience of seeing loved ones incarcerated and their lives destroyed by the criminal legal system,” Ms. Orlins said. “He understands those things fundamentally.”Ms. Crotty said it was important for Mr. Bragg to have a holistic vision of public safety for every neighborhood.“I think that that’s a responsibility he’s always taken seriously,” she said.On Tuesday, a number of voters in Harlem who said they had chosen Mr. Bragg described being impressed by what they perceived as his fundamental decency. Mimsie Robinson, 58, said that he heard Mr. Bragg speak at his church and had been struck by his integrity.“For me, a lot of times that’s what I’m looking at,” Mr. Robinson said. “Is this person sincerely committed to helping this community, this city, move forward?”Mr. Bragg, a graduate of Harvard Law School, began considering a career as a prosecutor while working for the federal judge Robert Patterson Jr., where he saw how influential those in the role could be. He worked for several years as a criminal defense and civil rights lawyer before being hired by the New York attorney general’s office, where he investigated public corruption and white-collar crime.After a stretch working for Mr. Bharara in Manhattan, he returned to the attorney general’s office, where he led a unit responsible for investigating police killings of unarmed civilians. He spent the final week before his election in a virtual courtroom, questioning members of the Police Department in a judicial inquiry into the circumstances that led to the killing of Eric Garner in 2014.