“I don’t compare myself to the councilwoman,” Mr. Capuano said in an interview. “In my mind I’m running on the basis of my record both back in Washington and back here.

“We’re in the fight of our lives with Donald Trump in the White House, and this district — like all districts, but particularly this one — needs the best fighter we can get in Washington, someone who’s experienced.”

In Somerville, his hometown, Mr. Capuano has held nearly every political office of import — alderman, mayor and now congressman — and he uses his campaign stops to gently remind voters that his history of leftist activism could stand next to anyone’s. Mr. Capuano has stressed to voters that, if Democrats retake the House, his seniority and relationships with other lawmakers would make him a prime candidate to sponsor bills and serve on valuable committees that are critical for achieving results. Ms. Pressley would be a freshman.

Ms. Pressley has long been an advocate for girls and women. She volunteered at little-known nonprofits, served as a mentor and Big Sister and has been a regular presence at events like the Boston Area Rape Crisis Center’s annual Walk for Change.

It was this background that led some of Boston’s “kingmakers,” Ms. Pressley said, to suggest in 2009 that she not run for City Council and instead pursue a career with nonprofits.

Ms. Pressley ignored their advice. From her years of working for Representative Joseph P. Kennedy II and former Senator John Kerry, including as Mr. Kerry’s Massachusetts political director during his 2004 presidential campaign, she had built an extensive political network of her own. Senator Kerry even knocked on doors for her.

Ms. Pressley won that first race. And in 2011, in her first bid for re-election, she pulled in more votes than anyone else.