WASHINGTON — In a damning depiction of Donald Trump, the president’s former lawyer on Wednesday cast him as a racist and a con man who used his inner circle to cover up politically damaging allegations about sex, and lied throughout the 2016 election campaign about his business interests in Russia.

Michael Cohen, who previously pleaded guilty to lying to Congress, told lawmakers that Trump had advance knowledge and embraced the news that emails damaging to Hillary Clinton would be released during the campaign. But he also said he had no “direct evidence” that Trump or his aides colluded with Russia to get him elected, the primary question of special counsel Robert Mueller’s investigation.

“I am not protecting Mr. Trump anymore,” Cohen declared.

Cohen, shaking off incessant criticism from Republicans anxious to paint him as a felon and liar, became the first Trump insider to pull back the curtain on a version of the inner workings of Trump’s political and business operations. He likened the president to a “mobster” who demanded blind loyalty from underlings and expected them to lie on his behalf to conceal information and protect him — even if it meant breaking the law.

“I am not protecting Mr. Trump anymore,” Cohen declared.

His matter-of-fact testimony about secret payments and lies unfolded as Trump met with North Korean leader Kim Jong Un, offering stark TV counterprogramming to the president’s official duties. At a Vietnam hotel and unable to ignore the drama thousands of miles away, Trump lashed out on Twitter, saying Cohen “did bad things unrelated to Trump” and “is lying in order to reduce his prison time.”

In testimony that cut to the heart of federal investigations encircling the White House, Cohen said he arranged hush money payments to women on Trump’s behalf and lied about them to the public and the first lady at the president’s behest. He agreed to say Trump was “not knowledgeable” about the transactions even though the president directly reimbursed him, and said he was left with the unmistakable impression Trump wanted him to lie to Congress about a Moscow real estate project, even if the president never directly told him so.

In one revelation, Cohen said prosecutors in New York were investigating conversations Trump or his advisers had with him after his office and hotel room was raided by the FBI last April. Cohen said he could not discuss that conversation, the last contact he said he has had with the president or anyone acting on his behalf, because it remains under investigation.

The appearance marked the latest step in Cohen’s evolution from legal fixer for the president — he once boasted he’d “take a bullet” for Trump — to a foe who has implicated him in federal campaign finance violations. The hearing proceeded along parallel tracks, with Democrats focusing on allegations against Trump while Republicans sought to undermine Cohen’s credibility and the proceeding itself.

As Republicans blasted him as a convicted liar, a mostly unrattled Cohen sought to blunt the attacks by repeatedly acknowledging his own failings. He called himself a “fool,” warned lawmakers of the perils of blind loyalty to a leader undeserving of it and pronounced himself ashamed of what he’d done to protect Trump.

“You make mistakes in life and I’ve owned them and I’ve taken responsibility for them, and I’m paying a huge price, as is my family,” Cohen said during testimony that spanned roughly seven hours.

Cohen will soon report to prison for a three-year sentence. At the same time, he is seen as a vital witness for federal prosecutors because of his proximity to the president during key episodes under investigation and their decade-long professional relationship.

The first of six Trump aides charged in the Trump-Russia investigation to testify publicly about crimes committed during the 2016 campaign and in the months that followed, Cohen also delivered biting personal commentary on a president he said never expected to win in the first place.

He recalled how Trump made him threaten schools he attended to not release his grades and SAT scores, mocked his own avoidance of the Vietnam War and denigrated blacks as “too stupid” to vote for him.

“He never expected to win the primary. He never expected to win the general election,” Cohen said. “The campaign – for him – was always a marketing opportunity.”

Cohen gave lawmakers his first-person account of how he arranged to buy the silence of a porn actress and a Playboy model who said they had sex with Trump. He described a February 2017 conversation with Trump in the Oval Office in which the president reassured him that reimbursement checks sent through Federal Express were coming but would take some time to get through the White House system.

He said the president called him a year later to discuss the public messaging around the payments, and had even once put his wife, Melania, on the phone so that he could disavow knowledge.

“Lying to the first lady is one of my biggest regrets,” Cohen said. “She is a kind, good person. I respect her greatly, and she did not deserve that.”

In an allegation relating to Mueller’s probe, Cohen said he said he overheard Trump confidant Roger Stone telling the candidate in the summer of 2016 that WikiLeaks would dump damaging information about Clinton.

Trump put Stone on speakerphone and Stone told him that he had communicated with WikiLeaks founder Julian Assange and that “within a couple of days, there would be a massive dump of emails that would damage Hillary Clinton’s campaign,” according to Cohen. Damaging emails that U.S. officials say were hacked by Russia were later released by WikiLeaks.

Trump responded by saying “wouldn’t that be great,” Cohen said.

Stone disputed that account Wednesday.

Cohen’s claims that Trump had advance knowledge of the emails contradict the president’s assertions that he was in the dark, and it is not clear how legally problematic that could be for Trump anyway. Mueller has not suggested that mere awareness of WikiLeaks’ plans, as Stone is purported to have had, is by itself a crime.

Cohen also suggested Trump implicitly told him to lie about a Moscow real estate project. Cohen has admitted lying about the project, which he says Trump knew about as Cohen was negotiating with Russia during the campaign. Cohen said Trump did not directly tell him to lie, but “he would look me in the eye and tell me there’s no business in Russia and then go out and lie to the American people by saying the same thing.”

Cohen said he does not have direct evidence that Trump colluded with the Russian government during the election, but that he has “suspicions,” including after a June 2016 meeting between the president’s oldest son and a Kremlin-connected lawyer.

“I wouldn’t use the word ‘colluding.’ Was there something odd about the back-and-forth praise with President Putin?” Cohen said. “Yes, but I’m not really sure I can answer the question about collusion.”

Federal prosecutors in New York have said Trump directed Cohen to arrange payments to buy the silence of porn actress Stormy Daniels and former Playboy model Karen McDougal in the run-up to the 2016 campaign. Cohen has said he acted out of “blind loyalty.”

He said he was presenting the committee with a copy of a check Trump wrote from his personal bank account after he became president to reimburse Cohen for the hush money payments. He claimed he had other exhibits as well, including some financial statements.

On the matter of racism, Cohen said the president made comments “disparaging African-Americans, saying at one point that black people would never vote for him because they were “too stupid.”

He said that Trump once confided to him that, despite his public explanation of a medical deferment from the Vietnam War, he never had any intention of fighting there.

“You think I’m stupid, I wasn’t going to Vietnam,” Cohen quoted Trump as saying.

“I find it ironic, President Trump, that you are in Vietnam right now,” Cohen said.

Associated Press writers Laurie Kellman, Lisa Mascaro, Chad Day, Michael Balsamo and Colleen Long contributed to this report.

READ MORE: Michael Cohen expected to claim lying, racism and cheating by Trump