Trucks travel along a loading dock at the port in Long Beach, Calif., in August. (Marcio Jose Sanchez/AP)

The U.S. economy grew at a strong 3.5 percent annual growth rate in the third quarter, buttressing Republican claims that President Trump is presiding over a boom, with just 11 days remaining before congressional elections.

Growth dipped from the second quarter’s 4.2 percent rate, but the economy still posted its best back-to-back quarters in four years — thanks to free spending by consumers and the federal government — and is within reach of the Trump administration’s 3 percent annual growth target.

“Despite all the hand-wringing about the [stock] market, the economy is looking pretty good,” said Ethan Harris, head of global economics for Bank of America Merrill Lynch. “The story here is a double dose of caffeine from tax cuts and spending increases.”

Vice President Pence on Friday touted the 3.5 percent growth, writing on Twitter that, under Trump, “the American economy is making a REAL COMEBACK after nearly a decade of slow growth.”

The strong headline growth number capped a volatile week on Wall Street, where the Dow Jones industrial average surrendered all of its gains for the year. The Commerce Department report Friday also offered a mixed verdict on prospects for the president to deliver an enduring era of improved economic performance and suggested that rising interest rates are beginning to bite.

“The details for growth were not as impressive as the 3.5% headline,” Jim O’Sullivan, chief U.S. economist for High Frequency Economics, said in an email.

The administration advertised last year’s corporate tax cut as a spur to business spending on new machines, computers and factories. Yet the evident gains earlier this year seem to be fading, the report showed.

Business investmentgrew by 0.8 percent in the quarter after an 8.7 percent gain in the previous three months. Spending on new structures fell by 7.9 percent after increasing by 14.5 percent during the prior period.

“That’s probably telling us that growth in Q4 will be a bit slower paced,” said Ben Ayers, senior economist for Nationwide Insurance.

Another major negative: Trade sapped the $20.7 trillion economy’s strength as imports outpaced exports by a rising margin, the report said. The president has made shrinking the trade deficit a key goal but has yet to see progress after 21 months in office.

Since January, Trump has slapped tariffs on foreign-made solar panels, washing machines and industrial metals and roughly half of the $505 billion in products that the United States imports each year from China.

His threats of additional tariffs on Chinese products may have encouraged U.S. companies to ramp up imports to beat rising prices, economists said.

The third-quarter results fell short of expectations set by the president, who had promised in July that the third-quarter figure would be “a lot higher” than the second quarter’s 4.2 percent.

Shortly after taking office in 2017, the president promised a “return to 4 percent annual economic growth,” a mark the United States has not achieved since 2000. But administration officials such as Treasury Secretary Steven Mnuchin more recently have described years of 3 percent annual growth as the objective.

Although the economic report is good news for the president, it will probably provide only a limited political boost for Republicans, according to Matt McDonald, a partner at Hamilton Place Strategies who worked as a White House communications aide for President George W. Bush.

“Where the administration has struggled is in tying the low unemployment rate and strong economy to any actions they’ve taken, like the tax cut,” he said.

By a margin of 61 percent to 30 percent, voters last month said Trump’s tax cut favored “large corporations and the rich” over “middle class families” in an internal Republican poll obtained by Bloomberg News.

Continued financial market volatility also may shake voters’ sense of well-being. The Dow fell more than 296 points Friday, continuing a slide that has shaved more than 2,100 points from the benchmark since Oct. 3.

Investors over the past month have lost more than 6 percent on the Dow and more than 10 percent with the technology-rich Nasdaq index.

The markets’ outlook is clouded by the Federal Reserve’s plans to continue raising interest rates. The nation’s central bank has increased short-term rates three times this year, to a range of 2 to 2.25 percent, and is expected to raise them again next month.

That is pushing up borrowing costs, which is pinching the housing industry. Residential investment fell by 4 percent, its third straight negative quarter.

With mortgage rates topping 5 percent, sales of new single-family homes last month fell 5.5 percent from the previous month to a seasonally adjusted annual rate of 553,000, the fourth consecutive monthly drop, according to a government report Thursday.

September’s sales volume was more than 13 percent lower than the same month one year earlier, and figures for the previous three months were also revised lower.

The Commerce GDP report — a preliminary estimate that will be revised twice in coming weeks — comes as Trump this week again criticized Fed Chair Jerome H. Powell for raising interest rates, calling the nation’s central bank the “biggest risk” to continued growth.

With the unemployment rate at its lowest mark since 1969, the Fed has been raising interest rates to prevent inflation from taking off. Prices are rising at an annual rate of 2 percent, according to the Fed’s preferred gauge.

Still, Friday’s economic news was better than most analysts had expected. Strong consumer and government spending boosted growth in the July-to-September period. A buildup in goods inventories also helped, suggesting potential weakness ahead if companies lower production while selling off any backlog.

“The economy is still growing significantly above its potential, which is pretty remarkable,” said economist Michael Strain of the American Enterprise Institute, citing an expansion that has not experienced a recession since 2009.

Friday’s report contained few signs of any lasting improvement in the economy’s fortunes. The fastest way to achieve higher living standards is for the nation’s workers, farmers and factories to produce more output with the same resources. But the United States has struggled for years to achieve higher productivity.

“Based on today’s number we estimate nonfarm business productivity increased at a 1.6% annual rate last quarter, and only 1.1% over a year ago,” economist Michael Feroli of JPMorgan Chase wrote in a note to clients. “This figure is right in the middle of the dismal rut it has been in over the past decade.”

The latest economic report card, which is prepared by career civil servants at the Commerce Department, capped a week of mixed economic news. On Thursday, the Census Bureau said new orders for durable goods rose a better-than-expected 0.8 percent in September. And the labor market remained strong, with new claims for unemployment insurance remaining near half-century lows, according to a separate Labor Department report.

As the Nov. 6 congressional elections loom, Republicans will celebrate the economy’s robust growth — while ignoring economists’ forecasts that growth will slow next year — and Democrats will complain that the gains are not being shared equally.

“The best is yet to come,” said House Ways and Means Committee Chairman Kevin Brady (R-Tex.) “I think there’ll be even stronger growth over the long term.”

The left-leaning Center for American Progress, meanwhile, said that “working- and middle-class workers” had yet to see any gains from Trump’s tax cut. Lower corporate tax revenue is leading to ballooning deficits and fueling Republican calls for cuts to Medicare and Social Security, the group said in an analysis of the GDP results.

Just one more major economic snapshot will be released before the midterm — the monthly job-growth and unemployment figures on Nov. 2.