Stocks on Friday finished their best June in decades, capping a strong first half of 2019 and a big rebound from May’s market downer. But the good news is tempered by the fact that investors relied on five giant companies for a third of the gains over the past quarter, reflecting the digital economy’s remarkable growth and its potential for fragility.

Three of the Standard & Poor’s 500 index leaders — Facebook, Apple and Amazon — have come under scrutiny from regulators and politicians in the past several months for their consumer dominance. Microsoft and Walt Disney round out the big five performers.

(Amazon founder and chief executive Jeff Bezos owns The Washington Post.)

The five companies together are worth more than $3.4 trillion as measured by the price of their stock. That is 14 percent of the combined value of all the companies in the S&P 500, according to Howard Silverblatt of S&P Dow Jones Indices.

“I would prefer broader market leadership and not such a narrow focus,” said Charlie Toole, portfolio manager at Adviser Investments. “When you have one or two or four names leading the market, you worry that if they trip up, it’s going to trip up the entire market.”

All three indexes are up on the year, with the S&P 500 climbing 17 percent in the first six months, the Dow Jones industrial average registering a 14 percent gain and the technology-heavy Nasdaq composite index leading everybody with 20 percent. All three are close to their all-time highs on a June bounce following remarks from Federal Reserve Chair Jerome H. Powell that “we will act as appropriate to sustain the expansion.”

The Dow closed at 26,599, up 73 points on Friday to finish June with a gain of 7.1 percent. It was its best first half since 1999 and best June since 1938, when it surged 24 percent. The S&P 500 closed at 2,941, up 16 points on the day and up 6.89 percent for June. The broad market posted its best first half since 1997. It was the S&P’s best June since 1955, when it climbed 8.2 percent. The Nasdaq composite finished up 38 points at 8,006, pushing its June rally to 7.4 percent. That’s the Nasdaq’s best June since 2000, when it gained 16.6 percent.

Stocks got a boost on several fronts toward the end of the week. The Federal Reserve signed off on stock buybacks and dividends for 18 big banks, spurring a rally in financial stocks. U.S. consumer spending in May increased moderately, feeding hopes for a Federal Reserve interest rate cut. Consumer sentiment rose slightly above forecasts, although the measure has slipped since early May, when it posted a 15-year high.

High-tech dominance has been the story of the past several years of the bull market, with Google, Facebook, Amazon and Apple nudging out legacy names like General Electric, Walmart and Exxon.

Money managers say investors need to own the big technology stocks or lose out.

“Technology is where you have the revenue and profitability growth, and that’s where stocks would be going up,” said Krishna Memani, vice chair of investments at Invesco. “The number of stocks that have been able to do that has been narrow, so investors are willing to pay a high premium for those stocks rather than for a paper company.”

The technology and communications service sectors, which cover four of the five leaders, together make up 30 percent of the S&P, according to Silverblatt. Technology is up 26 percent this year.

“I don’t want to talk down the stock rally because there’s only two or three stocks behind it,” said Chris Rupkey, chief financial economist at MUFG Union Bank. “A lot of times, the companies that are increasing at a greater rate naturally slow down and other companies come along and pick up the slack.”

Technology companies have been under increased attention from Republican and Democratic leaders and from government regulators in the United States and abroad who say Big Tech has become too powerful.

Facebook co-founder and former spokesman Chris Hughes has called for the breakup of the social media giant. The U.S. Justice Department and Federal Trade Commission have put Amazon, Apple, Facebook and Google parent Alphabet under heightened antitrust scrutiny.

Apple chief executive Tim Cook earlier this month disagreed with politicians such as Sen. Elizabeth Warren (D-Mass.), a presidential candidate who has called for the company’s breakup. Cook said in an interview on “CBS This Morning” that Apple is not a monopoly, but he said, “Scrutiny is fair.”

Investor Michael Farr, president of wealth-management firm Farr, Miller & Washington, said today’s market leaders will sooner or later run out of steam, prompting investors to look for new faces or even to latch on to some old names that have been ignored and are cheap.

“Everybody wants to bet on yesterday’s fastest horse,” Farr said. “They don’t care if they are healthy. But you have horses dropping dead, and you’ve got to find a fresh one to ride.”

Aerospace giant Boeing was among the Dow’s best performers in 2018, but its stock has dropped around 20 percent in the past four months over its 737 Max problems. Disney shares, on the other hand, have risen more than 25 percent in the past two months, boosting its market cap by around $50 billion.

Memani, Rupkey and others see big upside in stocks through the rest of 2019, even as anxiousness prevailed Friday ahead of a critical meeting between President Trump and Chinese President Xi Jinping on the sidelines of the Group of 20 meeting in Japan.

Trump’s obsession with rising stock prices has been one of the hallmarks of his presidency. He even tweeted about the bull market, now in its 10th year, from the G-20:

”The Stock Market went up massively from the day after I won the Election, all the way up to the day that I took office, because of the enthusiasm for the fact that I was going to be President. That big Stock Market increase must be credited to me. If Hillary won — a Big Crash!”

Rupkey said Trump “will do whatever it takes to get stocks on track coming out of the weekend. The lesson of recent months is whatever the negative headline, somehow the trade talks get resurrected. So try not to hit the sell button.”

Between Trump’s stock market fixation and the Federal Reserve’s willingness to use the money supply to bolster returns, some investors say there is a safety net under the stock market.

“We have to recognize the power of the Fed,” said Kristina Hooper, global market strategist at Invesco. “The Fed has placed a ‘put’ under the stock market over the past decade and could do so once again.”

Hooper said investors might be concerned that the market is fragile because of its narrow leadership. “But that has occurred in the past, and it doesn’t have to end calamitously. The baton can get passed to other names.”