WASHINGTON (AP) — For more than three years, lobbyist Jim Slattery worked in Washington to secure the release in Ukraine of the imprisoned political rival of the country’s then-president. He said the work was sometimes harder than expected.

“I had a sense that there were people working on the other side,” he said, “but they were doing it pretty secretively.”

Slattery’s hunch was right. His unknown opponent: The consulting firm run by Donald Trump’s former campaign chairman, Paul Manafort, and his deputy Rick Gates, now the campaign’s liaison to the Republican National Committee.

Manafort resigned last week, shortly after disclosures by The Associated Press about his firm’s covert lobbying on behalf of Ukraine’s pro-Russian government at the time.

The U.S. Foreign Agents Registration Act requires people working on behalf of foreign political leaders to disclose their efforts to the Justice Department, but neither Manafort and Gates nor U.S. lobbyists they directed did. Working on the other side, Slattery filled out the required paperwork describing contacts with Congress and State Department officials including specific phone calls and emails and the topics of their discussions.

“I damn sure didn’t want to get in trouble violating foreign agent laws,” said Slattery, a former Democratic congressman from Kansas.

Manafort and Gates were working for Ukraine’s Party of Regions but said they did not represent Ukrainian political interests in the U.S. But emails and insider accounts obtained by the AP showed Manafort’s firm directed a multimillion-dollar lobbying effort between 2012 and 2014 that appeared to undercut public support for imprisoned Yulia Tymoshenko, who was considered a political prisoner by U.S. and European governments.

In the emails, Gates showed familiarity with U.S. lobbying rules and how mandatory disclosure reports could be used to gather intelligence on Slattery. In May 2014, as Slattery was lobbying on Tymoshenko’s behalf, Gates directed Mercury LLC to monitor Slattery’s federal filings. In particular, Gates wanted to know the address of Slattery’s client and any information that could be gathered in the U.S. to complement similar digging in Ukraine.

Mercury and another Washington lobbying firm, the Podesta Group Inc., were working on behalf of the European Centre for a Modern Ukraine. The AP identified at least $2.2 million in payments to the firms. The nonprofit said it was independent, but documents released last week by anti-corruption investigators in Ukraine have tied the group to Ukrainian political figures.

The Podesta Group last week hired outside lawyers to investigate its role in the lobbying campaign and threatened to sue the European Centre. The Podesta Group has acknowledged the firm’s work with Gates but said it did not know Gates worked for Ukrainian political interests. An attorney for Mercury said it will also review the work.

The head of Mercury, Vin Weber, said his firm’s efforts were not intended to justify Tymoshenko’s imprisonment but to make the case that furor over her prosecution had obscured broader issues about Ukraine’s relationship with the West. But a Mercury employee who worked on the project told the AP the firm overtly opposed Tymoshenko’s release. This person spoke on condition of anonymity because employees are restricted from speaking publicly under signed, non-disclosure agreements.

“Everyone knew this was a shadow organization working for the greater good of the Party of Regions,” the employee said.

The employee said U.S. lawmakers objected to Mercury’s overtures and wanted Tymoshenko out of jail.

Slattery, the lobbyist, volunteered as an election monitor during Ukraine’s 2004 elections. He said he was impressed by protests against election fraud known as the Orange Revolution that peacefully played out in the frigid streets of Kiev. The family of Tymoshenko, who was prime minister from 2007 to 2010, asked for help when she was jailed following an election defeat in 2010.

When he learned about the covert lobbying campaign that opposed him, Slattery said that he was disappointed but not surprised. He said he hopes the U.S. government will look more closely at whether such behavior violated federal laws.

“You don’t want to be the only person in town complying with the law,” he said.

___

Associated Press writers Maria Danilova and Desmond Butler contributed to this report.

___

Follow Jeff Horwitz and Chad Day on Twitter at: http://twitter.com/JeffHorwitz and http://twitter.com/ChadSDay

Copyright 2016 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.