WASHINGTON — The former head of the Internal Revenue Service said he first learned in the spring of 2012, in the heat of the presidential campaign, that agents had improperly targeted political groups that vehemently opposed President Barack Obama’s policies.

But ex-Commissioner Douglas Shulman said Tuesday that he didn’t tell higher ups in the Treasury Department and he didn’t tell members of Congress.

And he wouldn’t apologize for it.

“I had a partial set of facts, and I knew that the inspector general was going to be looking into it, and I knew that it was being stopped,” Shulman told the Senate Finance Committee in his first public comments on the matter.

“Sitting there then and sitting here today, I think I made the right decision, which is to let the inspector general get to the bottom of it, chase down all the facts and then make his findings public.”

Shulman, who was appointed by President George W. Bush, left the IRS in November when his five-year term ended. His testimony makes him the top official to publicly acknowledge knowing before the presidential election that tea party groups had been targeted.

Even so, senators from both political parties said they were skeptical of the version of events portrayed by Shulman and Steven Miller, the man who took his place as acting commissioner and was forced last week to resign.

For more than 18 months during the 2010 and 2012 election campaigns, IRS agents in a Cincinnati office singled out tea party and other conservative groups for additional scrutiny when they applied for tax-exempt status. They asked who the groups’ donors were and the political affiliations of officers.