President Trump signaled Monday that he is reconsidering his announcement to freeze pay for more than 2 million federal workers, after hearing objections from Republican candidates in Virginia, a state with a large population of government employees.

Mr. Trump retweeted comments from Republican Senate candidate Corey Stewart, who said of the president on Twitter, “I’m confident he will do right by our federal workers, many of whom are my constituents in #Virginia.”

Mr. Stewart, chairman of the Prince William County Board of Supervisors, is trailing by double digits in his race against Democratic Sen. Tim Kaine. Virginia is home to more than 175,000 federal employees.

The Republican nominee also said federal workers “endured 8 years of hell” under former President Barack Obama, with several rounds of pay freezes and benefit cuts. He said Mr. Trump “can fix this, and I trust that he will.”

“As I travel the state this #LaborDay weekend, Virginians are saying they’re glad @realDonaldTrump is giving the federal pay raise another look,” Mr. Stewart tweeted on Sunday.

The president notified Congress in writing on Thursday that he intended to rescind a 2.1-percent pay increase for civilian federal workers scheduled to take effect Jan. 1. Mr. Trump cited budget concerns. The projected deficit for fiscal 2019 is about $1 trillion.

But on Friday, Mr. Trump said he wanted to “study” the issue over the Labor Day weekend, noting that federal employees haven’t had a pay raise “in a long time.”

The Senate has approved a 1.9-percent pay raise for federal workers, while the House hasn’t taken action on a pay raise. Some senior Democrats in Congress have vowed to move forward with plans for the increase.

Rep. Barbara Comstock, Virginia Republican whose district includes thousands of federal employees and who is in a tough re-election battle, wrote to Mr. Trump Friday to urge him to reconsider the pay freeze.

“We simply cannot balance the budget on the backs of our federal employees,” Ms. Comstock wrote. “With our strong, booming economy, I know we can work to find ways to support and fairly pay our federal employees, while growing the private-sector economy and reducing our deficits.”

Her Democratic opponent, state Sen. Jennifer Wexton, said in a statement, “Donald Trump and Barbara Comstock blew a $2 trillion hole in the federal deficit by giving a tax handout to the wealthiest and big corporations, and now they’re going to pay for it on the backs of federal workers by denying them scheduled pay raises.”

Federal civilian workers received a 1.4-percent pay raise this year, and 1-percent pay increases in the previous three years.

The president said the “locality” pay raises that vary from region to region based on cost of living would cost the federal Treasury $25 billion, not including the cost of the 2.1-percent across-the-board pay hike. The White House Office of Management and Budget has estimated that the government would spend $198.5 billion on pay for federal civilian employees in 2019 if the 2-percent raise were included.

The president’s announcement of a pay freeze came after the government reported that the U.S. economy grew at a strong 4.2-percent annual rate in the second quarter.

Democrats and federal workers’ unions noted that the nonpartisan Congressional Budget Office has estimated the GOP tax cut will increase the budget deficit by $1 trillion over the next decade, and that Mr. Trump reluctantly signed a bill in March to raise federal spending by nearly $300 billion.

Mr. Kaine asked on Twitter, “How many millions did the deficit-busting Trump tax cut put into his own pockets? But it’s federal employees who are hurting our fiscal situation?”

The proposed pay freeze would not affect the military. Service members are due to receive a 2.6 percent pay raise in fiscal 2019, the largest in nine years.

On Labor Day, Mr. Trump also hit back at AFL-CIO President Richard Trumka’s criticism of him and said the administration’s economic policies have lowered the unemployment rate to 3.9 percent.

“Some of the things he said were so against the working men and women of our country, and the success of the U.S. itself, that it is easy to see why unions are doing so poorly. A Dem!” Mr. Trump tweeted about Mr. Trumka, leader of the nation’s largest labor federation.

Mr. Trumka said Sunday in a Fox News interview that Mr. Trump’s policies are hurting workers.

“To date, the things that he’s done to hurt workers outpace what he’s done to help workers,” Mr. Trumka said. “He hasn’t come up with an infrastructure program that could put a lot of us back to work.”

He said wages have declined this year and asserted, “Overall, workers aren’t doing as well.”

Mr. Trump, who reached a tentative trade deal last week with Mexico to revise the North American Free Trade Agreement, tweeted Monday, “Our country is doing better than ever before with unemployment setting record lows. The U.S. has tremendous upside potential as we go about fixing some of the worst Trade Deals ever made by any country in the world.”