The Democratic victory marks a concrete rebuttal to the president’s political agenda less than a year into his second term.