WASHINGTON — President Trump signed the most consequential tax legislation in three decades on Friday, even as he complained that he has not been given credit for his administration’s accomplishments during a turbulent first year.

Mr. Trump decided against doing a formal signing ceremony early next year because television news networks questioned whether he would keep his promise to sign the legislation before Christmas.

Mr. Trump said he saw the coverage Friday morning and hastily called his staff to say that the legislation needed to be signed “now,” prompting a last-minute Oval Office ceremony for the president’s greatest achievement in his first year in office.

“We did a rush job today,” Mr. Trump said at the bill signing. “It’s not fancy, but it’s the Oval Office. It’s the great Oval Office.”