In April, he jumped into the Senate race in New Hampshire, attempting to become the third person ever, and the first in more than a century, to represent more than one state in the Senate.

But Ms. Shaheen, 67, a former governor who was first elected to the New Hampshire state senate in 1990, had developed deep bonds with voters that proved a challenge for Mr. Brown to overcome. “It was an honor to carry the flag, and I thank you for the privilege of being the nominee,” Mr. Brown told his dispirited supporters, adding that he had called Ms. Shaheen to congratulate her.