Maryland Gov. Martin O’Malley (D) has donated $38,000 to a veterans fund to offset past campaign contributions tied to businessman Jeffrey E. Thompson, who is accused of funding a “shadow campaign” for District Mayor Vincent C. Gray (D), an O’Malley aide said.

There is no evidence of wrongdoing on behalf of O’Malley’s campaign, but O’Malley decided after learning of the allegations involving Thompson last week to shed the contributions, said O’Malley spokesman Rick Abbruzzese. The campaign has followed the same practice upon discovering other tainted donations, he said.

“There was no illegal activity on the part of the campaign,” Abbruzzese said. “But the governor felt we should take the step of donating those contributions.”

The $38,000 was contributed to O’Malley’s 2010 campaign by Thompson and his business entities, Abbruzzese said. The money also includes checks from Jeanne Clarke Harris, a public relations consultant, who admitted as part of a plea deal that she helped disburse and conceal Thompson’s funds.

O’Malley has donated the money to the Maryland Veterans Trust Fund, which was created by a law O’Malley signed in 2009. Money from the fund is used to offer assistance to veterans and their family members who are in financial trouble and to help private organizations that aid veterans.

President Obama has also recently unloaded contributions from Thompson, returning $10,000 in checks written to his campaign and the Democratic National Committee.

Federal prosecutors have alleged that a secret $653,000 effort corrupted the 2010 mayoral race and helped Gray get elected in the District.

Thompson, owner of a health-care company and a prominent accounting firm, was not named in court proceedings last week or in prosecution filings.

But The Post has reported that multiple people familiar with the investigation confirmed that Thompson is the “co-conspirator” referred to by authorities for allegedly funding the “shadow campaign.”