Senator Kirsten Gillibrand of New York first decided she wanted to be a senator when she was 7 or 8. Two decades later, as a law firm associate, she went to an event featuring the first lady, Hillary Clinton, and heard her speech as a personal call to public service.

So Ms. Gillibrand — after waiting another 10 years — ran for Congress.

“It took 10 years volunteering to have the actual self-confidence to say, ‘I can run for office,’” she said. “Women are the biggest self-doubters.”

When women run for political office, they are just as likely as men to be elected. The main reason they are so underrepresented is that they don’t run in the first place.

Even as Americans near a vote that could elect the nation’s first female president, the pipeline isn’t filling up. The number of women serving in office stalled in the 1990s. Women now make up 19 percent of members of Congress, 25 percent of state legislators, 12 percent of governors and 18 percent of mayors. Recent data show the gender gap is just as glaring for the next generation of leaders.