Federal workers are more likely to be Democrats, according to surveys. But partisanship and ideology explain only some of the intense feelings among workers, many of whom have seen Democrats and Republicans in the White House come and go.

At bars after work, in employee break rooms, on conference calls and on social media networks, employees at agencies targeted for steep reductions fear for their jobs. They worry about Mr. Trump’s freeze on hiring and regulations, his pledge to reverse environmental protections, and his executive order shutting down immigration for refugees and people from seven predominantly Muslim countries.

Some federal workers welcome Mr. Trump’s promises to create new jobs, build infrastructure and lower taxes. Others say they are focusing on doing their jobs and trying not to be distracted by the political noise that surrounds them. Still others say they are struggling with the question of whether they want to work for a president with whom they so strongly disagree.

“What do you do,” asked Representative Gerald E. Connolly, Democrat of Virginia, if you work at a place where the leader “avowedly renounces the work of that agency?”

“All of a sudden, you are faced with a real moral dilemma,” continued Mr. Connolly, whose district just outside Washington is home to thousands of federal workers.

Federal workers watched with growing alarm last year as Mr. Trump waged a campaign filled with antigovernment bombast and then during a transition in which he recruited cabinet secretaries hostile to the agencies they lead. Now they wait in these chaotic early days of Mr. Trump’s presidency as he and his political advisers use executive orders to shred the policies and traditions the workers have championed.

The intensity of feeling was already raw in late December, when members of the Digital Service gathered for drinks at the Laughing Man Tavern, a Washington bar, to say goodbye to Mikey Dickerson, their boss and the Google engineer first hired to rescue HealthCare.gov, the government’s Affordable Care Act website.