Democratic gubernatorial nominee Andrew Gillum celebrates his primary victory with supporters during his election watch party in Tallahassee on Tuesday. (Joe Rondone/AP)

Victories by African American and Latino candidates in two competitive gubernatorial primaries on Tuesday highlight the Democratic Party’s success this year in expanding its ranks to non­white nominees.

Andrew Gillum, the African American mayor of Tallahassee, and David Garcia in Arizona broke through because of a coalition of their local networks and the help of outside groups intent on changing the white, male hue of the governing class.

In Florida, activists and liberal donors coalesced around Gillum, who was long counted out of the race because of a corruption investigation in his city’s government as well as the powerful family ties of his chief opponent. In Arizona, they boosted Garcia, an educator who supports raising taxes to increase teachers’ salaries.

Both candidates support statewide universal health care, both want U.S. Immigration and Customs Enforcement to be replaced, and both call for a ban on assault weapons. Neither seemed destined for a victory without the outside help.

“We’re light-years [ahead] of where we were a decade ago,” said Julián Castro, a former San Antonio mayor and secretary of Housing and Urban Development who supported Gillum through his Opportunity First PAC. “I’m convinced that the new resources and the raising of his profile gave him the momentum to go over the top.”

The growing diversity of the Democratic field has been welcomed by the party’s establishment and its most visible leaders, even as insurgents have pushed aside some establishment candidates. Democrats celebrated when they nominated 10 women for governor — a record — and again as women made up the majority of the party’s candidates in swing House seats.

The primaries have in many cases swept in a generational change: Gillum is 39 and Garcia, 48.

They also have elevated the party’s left and set up dramatic contests in the fall with Republicans who have fashioned themselves in the mold of President Trump.

Not all of the most liberal candidates have won, but that flank of the party has emerged with more bragging rights than it had in 2016, when Hillary Clinton’s resilient support from women and non­white voters led to the defeat of her Democratic presidential primary opponent, Sen. Bernie Sanders (Vt.). Sanders has now endorsed successful non­white gubernatorial nominees in Florida, Georgia and Maryland.

“We are doing what we were told to do after 2016,” said Ayanna Pressley, a black Boston City Council member, referring to encouragement by former president Barack Obama and others to become involved in politics. She is challenging Rep. Michael E. Capuano in next month’s Democratic primary in Massachusetts. “There are things I will highlight that other people in our delegation might not, because my lens is different.”

Gillum knitted together activists and large donors to boost a campaign that trailed in fundraising, behind front-runner Gwen Graham, a former House member whose father was a governor and senator, and former Miami Beach mayor Philip Levine. Gillum, who had lost some donors over the ongoing FBI corruption investigation of city contractors, was helped late in the campaign by a $250,000 donation from George Soros to an allied PAC, and by a $1 million investment from Tom Steyer in his NextGen America voter outreach organization.

More support came from organizations that had formed in Florida in the wake of the 2013 killing of Trayvon Martin — among them Dream Defenders Action, which, like Gillum, called for an end to Florida’s “stand your ground” gun law, which allows Floridians to shoot when they feel threatened and which some cited as a defense for Martin’s killer, George Zimmerman. Gillum, who had been a youth organizer with People for the American Way, was endorsed by various national liberal groups, including the black-focused Collective PAC, Indivisible Action, and Our Revolution, which Sanders founded.

“People are excited about candidates who don’t just run against Trump, but who name the racism and bigotry and division that defines Trump’s Washington,” said Adrianne Shropshire, the executive director of Black PAC, which has spent millions of dollars organizing and advertising to black voters. “Black voters in polling don’t see the economy getting any better. Many see it getting worse. They want diverse leaders who understand that.”

Garcia and Gillum — like Maryland’s Ben Jealous and Georgia’s Stacey Abrams, two other African American gubernatorial nominees this year — were also backed by the New York-based Working Families Party. Founded as a political party — in New York, candidates can run on multiple ballot lines — the WFP has expanded swiftly into a sort of grassroots-in-a-box campaign organization.

Under Maurice Mitchell, its first black leader, the WFP prioritized races in which more diverse and liberal candidates are poised to overthrow entrenched Democrats. “You need to be able to shift people’s political consciousness, about what is possible, to get them to engage in certain political fights,” Mitchell said in an interview before Tuesday’s primaries.

At the state level, the most successful non­white or non-male insurgents have matched the external assistance with preexisting political connections, often from elective experience.

Gillum, who has served as mayor since 2014 after 11 years on the city commission, had been viewed as a rising star with time to wait for an opening; his backers helped push that opening to this year.

Abrams, whose growing media brand has included the cover of Time magazine, was the leader of her party in Georgia’s state House. Jealous, who has struggled in the general-election campaign against a popular incumbent, had established bonds with activists as president of the NAACP.

With the exception of Alexandria Ocasio-Cortez, a political activist who had never run for office before ousting Rep. Joseph Crowley in a Democratic primary in June for a House seat in New York, pure upsets have been rare this year. On Tuesday, the insurgent group Justice Democrats had seven endorsed candidates on the Arizona and Florida ballots. Six of them lost; the seventh, Rep. Raúl M. Grijalva (Ariz.), had no challenger and was endorsed because of his institutional ties. Ocasio-Cortez remains the only candidate who has ousted a Democratic incumbent in a House primary.

The next test may come in Delaware in a Senate primary that will be held on Sept. 6. Sen. Thomas R. Carper (D) had been considered the clear front-runner over Kerri Harris, a black lesbian miliary veteran and social worker running for office for the first time.

But Ocasio-Cortez and the WFP both dispatched staff members to the tiny state, aiming at two things that no Carper challenger had tried: identifying enough voters to win a sleepy primary, and informing liberal voters of the bank-friendly senator’s record.

Two months later, the task remained difficult, in part because Harris had not made the sort of connections Jealous, Gillum and Abrams had made — she had no existing political network, and was reaching for help from outside activists and donors for the first time. Private polling has found Carper comfortably ahead, vulnerable only if Democratic voters learn that he has cast key votes with Republicans. The night of Florida’s primary, the WFP announced that it was spending $100,000 to contact at least 40,000 voters, in a primary in which turnout could be as low as 60,000.

Harris represents, however, a potential quandary for those inclined to support the insurgent nominees: What happens if they turn out to be weaker general-election candidates than the moderates they defeated?

“I hope people who want to see left candidates win move away from the mentality that backing an incredible person who loses diminishes your power,” said Claire Sandberg, a digital strategist who worked for Sanders and now works on the WFP’s Delaware campaign. “We should take a holistic view of what we can achieve by running transformative, left-wing candidates and believing in them.”

Harris, who has lagged far behind Carper in fundraising and endorsements, has not united all the forces that endorsed Gillum, Garcia and Abrams. But she has put together the state’s first credible primary challenge of any Democratic incumbent in this century. In a Monday night debate, she put him on the defensive by arguing that a 71-year old white man with a powerful “network” was alienated from poor and non­white voters.

“There are real numbers he doesn’t even understand,” Harris said in an interview after the debate. “I spend $15 for diapers because I buy Walmart brand; I can’t afford Huggies. He says 90 percent of people have health care; I know that they can’t afford it. He says wait, and I say we can’t wait to be taken care of.”