NEWARK — Philip D. Murphy, a former Goldman Sachs executive, cruised to the Democratic nomination for New Jersey governor on Tuesday while Kim Guadagno, the state’s lieutenant governor, easily turned away a spirited challenge to claim the Republican nomination, setting the stage for a November battle to replace Chris Christie, the deeply unpopular incumbent.

Their matchup, the first open election for the governor’s seat in New Jersey since 2005, promises to be as much a referendum on the administration of Mr. Christie — who will leave a state crippled by debt, credit downgrades and creaky infrastructure — as it will be an early test of the electoral impact of Donald J. Trump’s presidency.

“People all across New Jersey are demanding change, and I am here to change things,” Mr. Murphy told a crowd to loud cheers on Tuesday night at his election night party at a hotel in Newark. “Four more years of Chris Christie-style politics won’t make New Jersey the state where we draw the line against Donald Trump. But we will.”

For Mr. Murphy, who served as ambassador to Germany under President Barack Obama, the primary victory caps a yearslong effort to lay the groundwork for a run in which he invested more than $16 million of his own funds and vastly outspent his rivals. It elevates his unique brand of progressive policies and fiscal reform in a state facing a potential crisis over unfunded pensions and underfunded schools, combined with the highest property taxes in the country. It also vaults him into the national dialogue as an early Democratic response to Mr. Trump’s policies.