Correction: An earlier version of this story incorrectly identified Ricky D. McCoy. McCoy said he was a transportation security officer at Chicago O’Hare International Airport and president of Local 777 of the American Federation of Government Employees. The Transportation Security Administration had recently fired and the AFGE said he no longer held his union post. said after the article appeared that he will appeal his termination from the TSA. This version has been corrected.

It’s no secret that federal workers are feeling worn down. They’ve had their salaries frozen and are at the center of a partisan debate over the value of their work.

A report due out Thursday, based on the largest sample ever of the workforce of 2 million, confirms a steady decline in morale and ebbing commitment.

Despite positive feedback at some agencies, job satisfaction across the government has hit its lowest point in almost a decade. Just 52.9 percent of employees at the sprawling Department of Homeland Security, for example, are satisfied with their jobs, making it the lowest-ranked large agency, followed by the Department of Veterans Affairs.

The seventh annual “Best Places to Work in the Federal Government” rankings pose a challenge for the Obama administration as President Obama, who pledged to reinvigorate federal work and make government “cool again,” embarks on a second term.

Even workers at layoff-battered private companies are more optimistic than government employees, who historically have had far more job security, the survey by the nonpartisan Partnership for Public Service found.

Still, most federal workers say they are committed to the missions of their agencies.

“We work for a horrible agency, but we do great work,” said Ricky D. McCoy, a recently fired transportation security officer at Chicago O’Hare International Airport and former president of Local 777 of the American Federation of Government Employees. Just 32 percent of employees at the Transportation Security Administration, part of DHS, are satisfied with their pay, which is among the lowest in the government.

McCoy said he expects the TSA’s first collective-bargaining agreement, signed in November, to improve morale. “We’re hopeful now that things will turn in our direction,” he said.

DHS, which was created after the attacks of Sept. 11, 2001, has suffered from high turnover in top jobs. Spokeswoman Marsha Catron said leaders are “focused on continuing to improve employee engagement” with better communication from managers, training and rewards for good work.

But in some corners of the government, workers are happy. Employees at NASA, which ranks as the best place to work in the government, give high marks to leaders and supervisors and a culture that encourages telework. Most of all, they value their mission to continue space exploration even as the 30-year-old shuttle program was retired last year and the transition to new deep-space rockets has been slow.

“Our future was not as clear when people said goodbye to the shuttle,’’ said Jeri Buchholz, NASA’s personnel director. “But people rolled into new projects. They knew there really was a future in space exploration.” And no one lost their job.

Among large agencies, the intelligence community came in second, followed by the State Department, the Commerce Department and the Environmental Protection Agency. The small U.S. Army Audit Agency logged the highest score, with 85.7 percent of its workforce reporting good things about their positions and bucking a troubling trend.

Government-wide, 60.8 percent of employees were satisfied with their jobs this year. It’s the lowest score since the partnership began reporting the rankings in 2003 and a drop of 3.2 percentage points from last year. Even workers’ commitment to their agencies’ missions, the main driver of government work for many, is ebbing.

Workers’ perceptions of their leaders were key to their job satisfaction. Attitudes about leadership — as well as factors including pay, advancement opportunities and rewards for good performance — dropped. Many gains from 2008 to 2011 were erased.

Morale improved at a third of the 362 agencies and departments surveyed, according to the partnership and Deloitte, which draw their conclusions from data collected by the Office of Personnel Management. About 700,000 federal workers responded to the survey.

“We take these results very seriously,” said Controller Danny Werfel, who coordinates the Obama administration’s management initiatives from the Office of Management and Budget. “We need to understand where we can do better.”

Werfel said federal managers have a more granular understanding of their agencies than ever this year, because the census of the workforce was distributed to all permanent full- and part-time employees, compared with a sample of 266,000 last year and even fewer before that.

The budget office was the most improved of any agency, jumping 13.3 percentage points. Werfel attributes the shift to better communication and more flexibility at one of the most demanding workplaces in government.

He said the administration is “committed to addressing the problem” of leaders who fail to energize their staffs.

Even with persistent budget conflicts on Capitol Hill that leave workers uncertain about whether they can serve the public, Werfel noted that nearly all employees said their work is important, seek ways to improve it and are willing to make an extra effort.

But Max Stier, president of the partnership, called the growing lack of confidence in federal leaders an alarming trend that the administration needs to prioritize.

“Even with the external challenges, we’re seeing a failure of management,” he said.

The survey shows how important good leadership can be.

Debbie Matz, chairman of the National Credit Union Administration, attributed her mid-size agency’s jump from the 17th spot to No. 6 to stronger communication between managers and employees. A promotion test for examiners who audit credit unions also improved, she said. “With so many people using government employees as a punching bag, there’s a lot of angst, so employees tend to blame their managers,” she said.

Among mid-size agencies, a new category this year, the Federal Deposit Insurance Corp. took the top spot. The Broadcasting Board of Governors was at the bottom, followed by the National Archives and Records Administration, which has struggled with poor morale.

Archivist David Ferriero said feedback from employees and a new partnership with labor unions have identified key problems: The staff wants better training and more career development.

Among small agencies, the Surface Transportation Board, which regulates railroads, held on to its first-place ranking from 2011, with 84.3 percent reporting satisfaction.

The Office of the U.S. Trade Representative ranks as the worst small agency, at 32.7 percent. Former employees said its sense of mission was eroded by an ambivalent attitude toward free trade early in the Obama administration and during the economic crisis. Views of the agency’s leaders plummeted 18.9 percentage points over 2011.

Although 77.3 percent of government employees say they value their agencies’ missions, that support dropped slightly over 2011.

The Department of Veterans Affairs ranked 18th out of 19 large agencies. “We have a lot of issues and problems,” said Max Collier, assistant director of a VA community liaison program. “The VA is not as transparent as it should be. We haven’t had a pay raise in, what, three years now? To work here, you have to have a passion for helping veterans.”

He gestured to a plaque on the wall outside VA’s headquarters in downtown Washington displaying Abraham Lincoln’s famous words: “To care for him who shall have borne the battle and for his widow, and his orphan.”

“We’re not making chocolate bars here, we’re taking care of veterans,” Collier said.

Department results within agencies varied. The Commerce Department, for example, took the fourth spot among large agencies, with 80.3 percent of employees at the Patent and Trademark Office saying they’re happy, the result of a reduced backlog of applications and teleworking. But Commerce’s Office of the Inspector General ranked second from last among small departments, at 37.2 percent.

John Berry, the government’s personnel chief, said it’s critical that managers pay attention to the survey results, given the fiscal challenges they may face.

“The government is likely to be on a pretty strict diet for the foreseeable future in terms of resources,” he said. “We are encouraging every agency to dive into their results and pay attention to them.”

Josh Hicks, Howard Schneider and Steve Vogel contributed to this report.