By most measures, Warren Tolman should be running away with the race for attorney general. He was an accomplished state senator, has run for statewide office twice, has raised more money than his opponent, and is backed by the AFL-CIO and all four former attorneys general.

Yet Maura Healey, a former assistant attorney general making her first run for political office, has used her compelling biography as a onetime professional basketball player and advocate for gay rights to turn the contest into a neck-and-neck battle that is dividing the hearts and minds of Democratic activists.

Tolman, 54, has roots in the reform wing of the Legislature, and a record of passing significant tobacco, campaign finance, and ethics laws, as well as of taking on power players such as former Senate president William M. Bulger. He enjoys strong support from veterans of those battles, as well as from labor unions, thanks in part to his brother, Steven, the president of the state AFL-CIO.

But it has been 15 years since he served in office, and many voters, especially younger ones, have no memory of the laws he passed in the 1990s, or of his runs for lieutenant governor in 1998 and for governor in 2002.

Enter Healey, 43, a former top deputy to Attorney General Martha Coakley who has excited Democrats looking for a fresh face, and a chance to elect the first openly gay woman to statewide office in Massachusetts. She has won endorsements from women’s and gay rights groups, and is effectively tied with Tolman in the sprint to the Sept. 9 Democratic primary. In the Globe’s latest poll, Healey has the support of 28 percent of Democratic voters; Tolman has 26 percent.

“It’s caught me by surprise,” said Francis X. Bellotti, a former attorney general who supports Tolman and encouraged him to run. “I thought he would do a great job, and would win it without a great deal of competition, but she’s a threat.”

The candidates disagree on just a few issues — he supports casinos, she opposes them — and argue more about the proper role of the attorney general. Healey sees the job in the Coakley mold: a career prosecutor targetting unscrupulous lenders and fraudsters.

“Legislators, they debate, discuss, draft legislation, and vote,” she said, dismissing Tolman’s experience as a lawmaker. “The AG’s job is to sue, subpoena, investigate, prosecute, hold people accountable, and the arena is really the courtroom.”

Tolman says he couldn’t disagree more. He vows to use the attorney general’s bully pulpit to pressure colleges to combat sexual assault, to fight the National Rifle Association, and to push drug companies to stem opiate abuse.

“It’s not about being a courtroom litigator,” Tolman said. “It’s about leading: leading an office, leading people, standing up on issues that matter to the people of Massachusetts.”

When they argue about policy, the focus has been on so-called smart gun technology, which Tolman has driven to the forefront of the debate.

He wants to immediately issue a regulation requiring that all new guns sold in the state use the fingerprint technology, so they could only be fired by their legal owners.

Healey contends the attorney general does not have the authority to issue that regulation; she would seek legislation requiring it.

“It’s a small difference in terms of the outcome,” she said.

Tolman disagrees.

“I will use the office of the attorney general to do it. Maura won’t,” he said. “That’s a fundamental difference, plain and simple.”

Both candidates come from large families — he is the seventh of eight children, she the first of five — but charted very different courses into the race.

As a legislator, Tolman helped pass a first-in-the-nation law requiring tobacco companies to disclose the ingredients in cigarettes. The measure earned him the ire of Rush Limbaugh, a badge of honor Tolman never fails to mention. He also sponsored a law that limited campaign donations and banned gifts from lobbyists to legislators.

Pushing back against Healey’s attemps to paint him as a political insider, Tolman boasts that he never voted for Bulger for Senate president and helpd ban smoking in the State House “over the objections of the chain-smoking Senate president,” Bulger’s successor, Thomas F. Birmingham.

“I would ask someone to show me a legislator over the last 50 years who has exhibited more independence from the status quo on Beacon Hill,” Tolman said.

But after leaving office in 1999, he took on more lucrative work, some of which was does not fit comfortably with his reputation as a reformer.

Last year, he earned more than $300,000 as an attorney at Holland and Knight in Boston, as a vice president of EnTrust Capital, a New York investment firm, and as manager of Etain, a consulting firm he founded.

The Globe reported in April that Tolman was also director of business development at Fast Strike Games, which promotes technology designed to make betting appealing to young people. He then cut ties with the firm.

But Healey, noting the attorney general will oversee the casino industry, said, “Who do you trust to be the better regulator of the industry?”

She leans heavily on her years as a star point guard at Winnacunnet High School in Hampton, N.H., at Harvard, and in Austria, where she spent two years playing professionally for UBBC Wüstenrot Salzburg.

In her legal career, she is best known for arguing the state’s case against the Defense of Marriage Act, which led in 2010 to the first ruling in the nation to strike down the law.

Both candidates have raised large sums, but Tolman has pulled in more: $1.5 million, to Healey’s $1 million, allowing him to launch the campaign’s first television ad on Aug. 11. Healey plans to air her first ad soon.

On the campaign trail, both have charmed and interested voters.

Greeting a group of elderly Italian-American women playing bingo in the North End, Tolman showed off an ease that comes from years in the political arena.

“I’m an Irishman. Is that all right?” he said, as the women laughed. “My 90-year-old mother-in-law is a member of the Sons of Italy in Watertown, so I can’t be that bad.” Then he was off, declaring that “if some swindler calls your house and tries to sell you something and then you never get it,” he could help as attorney general.

Healey has her own touch, as well.

Recently, she met Celtics legend Bob Cousy, whose number, 14, Healey wore in high school and college. As Healey sat in Cousy’s living room, the 86-year-old Hall of Famer told Healey he admired her support for gay marriage, but acknowledged his endorsement wasn’t based purely on policy.

“At the end of the day, you’re a point guard who wore number 14, so how can you say no?” he told her.

Healey put a hand on Cousy’s shoulder and thanked him for the assist.

“Floor general to attorney general,” she chuckled. “It’s seamless, but I don’t know if it fits on a bumper sticker.”