Stein, like Gov. Roy Cooper, catapulted from the attorney general's office to the Executive Mansion.
The win makes Stein, 58, the first Jewish governor of the Tar Heel State. He defeated his Republican challenger Lt. Gov. Mark Robinson, who was hoping to become the state's first Black governor.
Polls consistently showed Stein with a double-digit lead on his less-well-funded opponent. Stein's campaign dramatically outraised and outspent Robinson.
"Tonight, the people of North Carolina soundly embraced a vision that's optimistic, forward-looking and welcoming," Stein said in his victory speech. "A vision that's about creating opportunity for every North Carolinian. We chose hope over hate, competence over chaos, decency over division. That's who we are as North Carolinians."
WATCH | Stein's full victory speech
Josh Stein gives victory speech in NC governor's race
Democrats have held the governor's mansion for all but four years since 1993, even as the GOP has held legislative majorities since 2011.
"I ran for governor because I love our home state and I believe in the promise of North Carolina - that where you come from should never limit how far you can go," Stein said. "That our kids and grandkids should enjoy a better and brighter future than we had."
Stein, the son of a prominent civil rights lawyer and a lawyer himself, was elected as a state senator in 2008 representing Wake County's District 16. and served in the general assembly until assuming the attorney general role in 2017.
LIVE BLOG | Latest updates on local and statewide races
"So tonight, let's celebrate this hard-fought victory," Stein said. "And tomorrow, we will get back to work building a North Carolina that is safer, stronger, and more prosperous for all."
He grew up in Chapel Hill and Charlotte and is a graduate of Dartmouth College, Harvard Law School and Harvard Kennedy School of Government. His top listed priorities during the campaign were making economic prosperity accessible for all residents, improving education and building a strong workforce.
The North Carolina Association of Educators (NCAE) congratulated Stein on his election.
"We are thrilled to call Josh Stein the next governor of our great state," the NCAE said in a statement. "With him, we know we have a committed partner who supports and values public education. We look forward to working with him to ensure that the 1.5 million children in our public schools receive the resources and support they need to succeed -- and to make North Carolina stronger."
As attorney general, Stein took credit with lawmakers for eliminating the backlog for testing thousands of sexual assault kits in police custody, saying it led to additional DNA matches for unsolved crimes. He also sued TikTok, alleging the company designed the app to be addictive and misrepresented the risks it posed to young users.
Stein angered Republicans with his decision to end the state's defense of a 2013 voter ID law that was struck down and of some abortion restrictions.
And while he co-chaired a task force in 2020 that offered scores of recommendations on how to eliminate racial inequities in criminal justice, liberal activists complained the next year that his office failed to do enough to protect civil rights.
Robinson burst onto the political scene in 2018 when he gave an impassioned speech at a city council meeting that went viral and served as a springboard to his historic run to the lieutenant governorship. Robinson often emphasized his blue-collar roots and working-class background to connect with voters and constituents.
His campaign was uneven and included controversial moments and legal entanglements, and ultimately voters decided to continue the path that Cooper had set for the state.
"We realized what we were up against from the very beginning," Robinson said Tuesday to his supporters. "We knew that we were just an ordinary person in this for the right reasons: To fight for the people of North Carolina, to make effective change."
Mark Robinson thanks supporters, says he's disappointed in result
He encouraged his supporters to remain optimistic.
"Whether people want it to or not, people of faith know it's going to go the right way, because we've read the back of the book, and we know this all comes to an end," Robinson said. "I'm standing here now, and I'm not sad one lick. I'm a little disappointed, I'm disappointed for you because I wanted this so bad for you, I wanted this for the people of North Carolina - not for me - I wanted it for them,"
Robinson said there is still a lot of work to do, including helping the people of western North Carolina who are recovering from Hurricane Helene.
Robinson added that after his term as lieutenant governor is up, he plans to spend more time with his grandchildren and then reassess his future.
The Associated Press contributed.