Rep. Elizabeth Esty (D-Conn.) said she consulted her personal attorneys and advisers regarding the allegation made against chief of staff Tony Baker. Later, emails show, she enlisted a friend to look into Baker’s past behavior. (Tom Williams/CQ Roll Call/Associated Press)

The threat from Rep. Elizabeth Esty’s chief of staff arrived in a voice mail.

“You better f-----g reply to me or I will f-----g kill you,” Tony Baker said in the May 5, 2016, recording left for Anna Kain, a former Esty aide Baker had once dated.

Kain, who provided a copy of the recording to The Washington Post, alerted the police, filed a report for felony threats and obtained a 12-month restraining order against Baker.

According to emails obtained by The Post, Esty found out about the episode within a week. At that point, the Connecticut Democrat took matters into her own hands.

Rather than firing or suspending Baker, the congresswoman consulted her personal attorneys and advisers, she said. She also spoke to Kain on May 11, emails show; Kain said she provided detailed allegations that Baker had punched, berated and sexually harassed her in Esty’s Capitol Hill office throughout 2014, while she worked as Esty’s senior adviser.

Later, Esty enlisted a friend, former chief of staff Julie Sweet, to look into Baker’s past behavior, emails show.

Baker did not leave for three months. By his last day on Aug. 12, according to documents Esty provided to The Post, he and Esty had co-written a positive recommendation letter he could use in a job search and signed a legal document preventing her from disparaging him or discussing why he left. Baker went on to work for Sandy Hook Promise, the gun-control group created after the 2012 shooting in Esty’s district. He was dismissed from the group this week after The Post contacted him.

The controversy over Esty’s handling of Baker’s dismissal was first reported Thursday by the Connecticut Post.

In retrospect, Esty said she dealt with the situation poorly. She said she plans to reimburse the U.S. Treasury for what she described as the roughly $5,000 Baker received in severance. She also plans to improve how she runs her office, she said.

“What I did was not good enough and it didn’t protect [my staff] enough,” Esty said Monday in an interview at her home in Cheshire, Conn. “ . . . I’m hopeful now with this conversation and this coming out that I’ll be able to be much more direct and help other people in Congress understand the risks they are placing their staff at when they don’t think they are.”

Baker referred questions to a friend, Andrew Ricci. Ricci said Baker disputed that he struck Kain. He said Baker had a drinking problem in 2016 but since then has been sober and received treatment for anger issues and substance abuse.

While the rise of the #MeToo movement has triggered a national reckoning on sexual harassment and ended the careers of many prominent men, the issue continues to be especially thorny in Congress, where, critics say, rules written and enforced by lawmakers are designed to protect the institution rather than victims of abuse. Alleged abusers have avoided penalties and negative publicity through nondisclosure agreements, such as the one signed in Baker’s case, and taxpayer-funded settlements that have been used to ensure accusers’ silence.

Esty’s case underscores how the harassment issue can be challenging even for lawmakers who, in their public positions, find common cause with #MeToo victims.

The congresswoman, a perennial target for Republicans, was among the Democrats who called on their colleague Rep. John Conyers Jr. (Mich.) to resign after he was accused last fall of serially harassing female staff members.

“For too long, the culture in Washington has accepted entirely unacceptable behavior,” Esty said in a statement in November after anti-harassment training became mandatory for House offices. “That needs to change — period.”

Esty provided The Washington Post with a copy of her agreement with Baker, which included multiple secrecy provisions, a draft recommendation letter and his severance terms. The document provides a rare look at a contract signed by a lawmaker and a departing senior staffer facing possible scandal, the result of a process that at no point sought a formal response from Kain.

In response to questions, Esty expressed remorse for her handling of Baker’s situation. She said she was pressured by the Office of House Employment Counsel to sign an NDA, a process that she said delayed Baker’s departure. She said she was working within a system that appeared designed to shield members who had misbehaved, not those trying to dismiss problematic aides.

“Clearly that’s what it’s all set up to do — to protect the member of Congress whose bad behavior caused the problem,” Esty said.

“It felt wrong to me. . . . When I’m reading the documents and these drafts, it kept going through my mind, ‘This is not right. This is not what happened.’ ”

Gloria Lett, lead counsel with OHEC, declined to comment, writing in an email that her office does not respond to media inquiries. She referred questions to the Committee on House Administration.

The committee said in a statement that OHEC “serves to provide advice to House employing offices on employment policies and practices” and that “ultimately, each member makes the final decision for how a case against the office is handled and an employee’s employment status.”

The statement said the committee “does not review any employment decisions” and “is not involved in the advice that OHEC provides.”

According to both sides, Kain and Baker met in Esty’s office following her 2012 election. They dated casually in 2013 before being promoted to senior adviser and chief of staff, respectively, in early 2014.

According to Kain’s petition for a restraining order, Baker punched her in the back and “repeatedly screamed” at her in Esty’s office while threatening to retaliate professionally if she reported his behavior. She did not tell Esty or the House Ethics Committee out of fear for her safety, her petition stated.

Kain told The Post that she was so anxious about imperiling her boss’s chance of reelection that she removed her cellphone from the House’s WiFi network so that she could privately look up how to report misconduct to the Ethics Committee.

“I was 24 and doing a job that I believed in for an institution I was proud to be a part of,” Kain said Thursday in an interview. “But I was being severely abused and had nowhere to turn. Nobody talked about things like this. I was suffering and thought it was weakness.”

On May 5, 2016, Baker called Kain approximately 50 times and said he would “find her” and “kill her,” she alleged in the petition.

Ricci disputed that Baker punched Kain but did not challenge her other allegations. He said that Baker was too intoxicated at the time to remember leaving the message and that he offered to resign after Esty learned what had happened. The congresswoman said Baker never offered his resignation.

Baker was barred from working out of Esty’s Capitol Hill office starting on July 24, 2016, according to the separation agreement, which required Esty to serve as a reference in his job search outside of Washington. A draft letter of recommendation from Esty that was attached to the agreement praised his “considerable skills.”

Baker accompanied the congresswoman to the Democratic National Convention in Philadelphia from July 25 to 28 before sending a departing email to colleagues on Aug. 12.

A spokeswoman for Sandy Hook Promise declined to comment on Baker’s departure this week.

Esty said she plans to advocate for greater accountability in how congressional offices are managed.

“I hope in the course of all of this we’re pulling the curtain back in a way that will make the institution truly better than it is now,” she said.

Kain urged the Senate to approve legislation to better protect its staffers, in line with recent changes to House policy.

“I just want people working on the Hill and going through this to know that it’s real, it’s a problem and nothing about it is okay,” she said.