Hillary Clinton became the first woman to capture the presidential nomination of one of the country’s major political parties on Monday night, according to an Associated Press survey of Democratic superdelegates, securing enough of them to overcome a bruising challenge from Senator Bernie Sanders and turn to a brutal five-month campaign against Donald J. Trump.

In a yearlong nomination fight full of surprise twists, from the popularity of Mr. Sanders to the success of Mr. Trump, the revelation that Mrs. Clinton had clinched the nomination was another startling development — especially coming on the eve of major primaries in California, New Jersey and other states. Mr. Sanders added to the drama by refusing to accept the A.P. survey and vowing to fight on, while Mr. Trump argued that he had done more for women than Mrs. Clinton.

Mrs. Clinton was ebullient but also restrained as she received the news at an uncanny moment — almost eight years to the day after she ended her campaign against Barack Obama before a crowd of many teary women and girls. On Monday night, she shared the breakthrough with a jubilant audience at a campaign stop in Long Beach, Calif.

“I got to tell you, according to the news, we are on the brink of a historic, historic, unprecedented moment, but we still have work to do, don’t we?” Mrs. Clinton said. “We have six elections tomorrow, and we’re going to fight hard for every single vote, especially right here in California.”