Republican US Senate candidate Michael J. Sullivan, a strong advocate for curbing government fiscal excesses and inside deals, has been trumpeting his refusal to accept a legislative pay raise in the 1990s, which he decried as political horse-trading at its most ­offensive.

But Sullivan, who is drawing strong support from the antigovernment, Tea Party wing of the GOP, has not always adhered to those conservative principles.

Under the terms of that deal, which allow district attorneys to begin collecting full pensions at 55 regardless of how long they served, the 58-year old Sullivan has been collecting a state pension of $27,492 a year for the past three years.

Sullivan, whom most polls show leading the three-way Republican ­primary race to fill the seat ­vacated by John F. Kerry, disputes any suggestion that his campaign profile conflicts with the pay hike and pension benefits.

He said he does not recall playing a role in either change, although he was president of the district attorneys association when the pay increase won initial approval. In 1996, when the pension benefit was approved, he said, “I wasn’t even thinking about a pension.”

Still, he defended the pension change, which has come under fire from conservatives and watchdog groups as a sweetheart deal for district ­attorneys trying to pad their ­retirement.

The change placed district attorneys in what is known as Group 4, a pension category that had once been reserved for front-line public safety workers who frequently face life-threatening situations. Before the change, district attorneys, like most other state workers, were required to wait until 65 to collect their full benefits, and only if they had worked for the state for at least 10 years. Under the new provision, district attorneys can technically qualify to collect full benefits at age 55, even if they served only one day in office.

Sullivan noted that prosecutors are frequently subject to death threats and violence, using as an example the recent shooting deaths of prosecutors in Texas. The push to allow state prosecutors to join the special Group 4 category followed the shooting death of Paul McLaughlin, a assistant Suffolk district attorney who was murdered by a Boston gang leader in 1995.

“I am confident the case was made to the Legislature and the governor,’’ said Sullivan. “I don’t think there is anyone who would suggest that there is not some risk being a prosecutor.’’ He noted he has ­declined to take the state’s health benefits for retirees, saving the state at least $12,500 a year.

A year before the Legislature bolstered the district ­attorneys’ pensions, it took a similar action for assistant district attorneys, but required them to be employed for at least 10 years before qualifying for a full pension at age 55.

“District attorneys are not the group that anyone had in mind when Group 4 was created,’’ said Charles Chieppo, a fiscally conservative public policy analyst who has studied and written extensively about state pension issues. “Group 4 was created with the idea it would enhance the pension for people who put their lives on the line every day. It was not designed for people sitting behind a desk.’’

Barnstable District Attorney Michael D. O’Keefe, the current president of the Massachusetts District Attorneys Association and a Republican, said, “It’s a job not without its danger.’’

“That’s something none of us, particularly those who knew Paul, will ever forget,” he said. “Now we see what has happened in the state of Texas, and it once again reinforces this is a dangerous job.”

Sullivan’s pension benefits also got a boost as a result of the 24 percent salary increase the Legislature approved for all district attorneys in January 2000, raising their pay from $95,000 to $117,490. It was ­negotiated and given initial ­approval in fall 1999, during Sullivan’s second and final year as president of the district ­attorneys association.

Sullivan said he does not ­recall any conversation he had with Democratic legislative leaders at the time, including House Speaker Thomas M. Finneran, whom he later prosecuted after becoming US ­attorney.

But the association’s lobbyist at the time, Robert F. White, said he specifically remembers Sullivan taking a direct role in securing the pay hike.

Initially, the lobbyist had negotiated an agreement with legislative budget leaders that would have given district attorneys an increase to $113,000 a year, White said.

“I was blindsided when ­Sullivan announced at an association meeting he had gotten a special commitment from the House Democratic leadership for $117,490,’’ White said.

Sullivan said he has no recollection of such an incident and dismissed White’s statement. He said he had “differences’’ with White when he was president of the association.

“He has held a grudge against me ever since I prosecuted Tom Finneran,’’ Sullivan said.

Sullivan oversaw the federal investigation of Finneran on obstruction of justice charges, stemming from his testimony in a federal voting rights case involving redistricting.

Finneran, a close friend of White’s, pleaded guilty in 2007.

The special pension deal for district attorneys has haunted several of them as they sought higher office. When he first ran for Congress in 1996, William D. Delahunt, then Norfolk district attorney, came under fire from his Democratic primary opponent, Philip Johnston, who called on him to refuse the Group 4 pension.

Delahunt brushed off the attack and, after winning the congressional seat, immediately applied for and received, at age 55, his $54,000 a year pension while collecting his $130,600 a year federal salary.

William R. Keating, the former Norfolk district attorney who won the seat Delahunt ­vacated in 2010, ran into criticism when he initially said he too would collect his Group 4 pension, $110,000, along with his $174,000 salary as a congressman.

Facing criticism, Keating, who is 60, backed down and said he would take the pension but donate the money to a health charity.