President Trump pushed aside a formal signing in January to sign the tax legislation because television news networks questioned whether he would keep his promise to sign the legislation before Christmas.Published OnDec. 22, 2017CreditCreditDoug Mills/The New York Times

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.”

It marked another improvisational moment in a presidency already known for abandoning the norms of the office.

The bill was the most significant legislative victory for Mr. Trump, who has struggled during his first year in office to pass major bills that would deliver on campaign promises, even with Republicans having the majority in both chambers of Congress. Republicans promise the new tax law will benefit the middle class, but Democrats have warned that the law could be harmful to many lower-income taxpayers and to the nation’s fiscal health.

“It’s going to be a tremendous thing for the American people,” Mr. Trump said.

Before signing the legislation on Friday, Mr. Trump said in a Twitter post that companies were celebrating the bill’s passage with bonuses for workers.

During the signing ceremony, Mr. Trump said, “Corporations are literally going wild over this.” A handful of companies, including AT&T, which is seeking government approval of a major acquisition of Time Warner, have announced that they would give bonuses to workers.

There was some discussion in Congress and at the White House that Mr. Trump should consider delaying the signing until early 2018 as a way to delay automatic spending cuts that could have been triggered by the tax cuts. In addition, some companies said that delay would give them more time to adjust to the major changes that the new tax code will mean for their businesses.

However, once Congress reached a deal this week to avoid the possibility of the spending cuts, White House officials signaled that Mr. Trump wanted to sign the bill into law as soon as possible.

Mr. Trump often reacts to television news, and Friday was no different. The president delayed his travel to Florida for the holidays by an hour to stave off potential criticism.

“Every one of the networks was saying, ‘Will he keep his promise?’ ” the president said.

Shortly after 10 a.m., Mr. Trump announced in a Twitter post that the bill would be signed “in 30 minutes.”

Earlier in the morning, the president suggested that he would not get credit for what he said were extraordinary accomplishments for a first year.

Under the new tax law, individual rates will be lowered, but those cuts are set to expire in 2025. The standard deduction, which will almost double, is likely to become more popular. The tax credit for children will also double, which Republicans have said will benefit lower-income families. The largest cut by far in the new tax law — which will not expire — benefits corporations.

The new law has been criticized by lawmakers representing states with high taxes, because the bill caps state and local tax deductions at $10,000.

The law also eliminates the Affordable Care Act’s mandate that most people have health insurance or pay a penalty. Mr. Trump has said that amounted to repealing President Barack Obama’s signature health care law, but 8.8 million Americans signed up for coverage, according to figures his administration announced on Thursday. The law is not repealed, but the mandate had been considered an important feature of it.

Mr. Trump also signed a stopgap spending bill in order to avoid a government shutdown. In addition to extending government funding, the bill includes $4 billion for missile defense, among other provisions.

A version of this article appears in print on , on Page A15 of the New York edition with the headline: President Signs Bill Into Law, and Seems to Ask for a Pat on the Back. Order Reprints | Today’s Paper | Subscribe