Amid one of the nation’s strongest earning seasons for retailers, leaders at Best Buy Co. Inc. managed to be both upbeat and cautious on Wednesday — sending its stock on a bumpy ride.

The company said comparable sales grew a solid 6.2 percent in the second quarter and raised its outlook for the rest of the year.

But executives cautioned that operating profit would decline as it spends more on transportation, training and technology, particularly in the third quarter.

The company now expects same-store sales on the year to rise 3.5 to 4.5 percent, compared with the previous forecast of a flat 2 percent. Earnings per share are expected to edge up to $4.95 to $5.10, an increase of 5 to 10 cents.

The forecast fell short of the exuberance Wall Street wanted in the lead-up to the crucial holiday season. Investors pushed shares down as much as 9 percent before ending the day at $77.57, off 5 percent.

Scot Ciccarelli, an analyst with RBC Capital Markets, said despite “positive attributes,” the consumer electronics market is full of competitors and lacking innovation. Holiday sales account for 50 to 60 percent of earnings. And with no clear must-have product to drive sales at Best Buy, Ciccarelli remains unconvinced that it will be a blockbuster season.

“Best Buy has vastly improved its competitive positioning through price-matching Amazon [and others] and forming in-store vendor partnerships with technology leaders such as Apple, Samsung, Microsoft and Google,” he said in a note. Yet even with tight cost controls, Ciccarelli said it will become increasingly difficult to drive sustained sales improvements in a deteriorating market for consumer electronics.

Chief Executive Hubert Joly urged a longer view, saying that progress “may not be linear.” He pointed to five consecutive quarters of same-store-sales gains above 4 percent as one of many signs of the company’s solid footing. Second quarter revenue hit $9.38 billion — showing its largest growth in 15 years for the period.

Best Buy is benefiting from a stronger economy, rising wages and tax policies that are putting more money in consumers’ pockets. It’s also gaining market share as RadioShack, Sears and other mass merchandisers close stores.

But Joly said the growth also was “driven by how consumers are responding to the unique and elevated experience we are building.”

For the three months ended July 29, the Richfield-based company said it earned $244 million, up from $209 million a year ago. Adjusted for one-time events, the profit amounted to 91 cents a share, beating the consensus ­estimate of 83 cents.

Even as shares tumbled, Moody’s retail analyst Charlie O’Shea described the company as one of the strongest performers in retail.

He noted that margins “are being largely maintained despite continuing investments, and meaningful online sales growth that continues despite the online maturity of many of its product ­categories.”

Joly acknowledged the slower pace of online growth in consumer electronics, cited as one reason for Wednesday’s sagging stock price, but said market share was growing and the company is more focused on sales across multiple ­channels.

Efforts to simplify online shopping and delivery — as well as its in-store pickup, now a decade old — have led to substantial contributions to revenue. Best Buy now gets 15 percent of total domestic sales from online purchases.

During the quarter, Best Buy announced an $800 million cash offer for GreatCall, a California-based company that develops mobile products to connect older adults with family caregivers, service providers and emergency services, aiming to help them live independently longer.

In his first public comments since the purchase, Joly told analysts he considers it a “beachhead for Best Buy in the health space, providing an entrypoint to more ­opportunities.”

The deal is expected to close by the end of next quarter.

Best Buy has been moving more aggressively into health and wellness products in recent years, aiming to anticipate the ways people use technology to do such things as improve their fitness or send an alert if an elderly parent hasn’t opened the refrigerator door.

It also has tried to more deliberately marry its Geek Squad expertise with its growing array of digital products, believing the two will work together to fuel growth in hardline sales and services.

The acquisition of GreatCall, which has nearly a million customers, gives the retailer another way to expand its home-adviser service and other programs aimed at helping people feel less overwhelmed by technology and gadgets.

Down the road, it also will enable the company to form partnerships with insurance companies and social service providers serving older adults, as it is already doing with its Assured Living service, Joly said.

“The human aspects and the economic aspects go hand in hand,” Joly said. While many companies see business opportunities in the coming age boom, “very few go into people’s homes and have people install and support the technology.”

Best Buy began offering its free in-home consultation service last September and has focused on training a growing cadre of employees, an expense that is cutting into short-term profits. The company said it now has 430 home advisers, up from 300 at the start of the rollout.

Its subscription-based Total Tech Support program, which it started at the end of May, gives consumers access to Best Buy’s Geek Squad expertise.

The company is betting that expenses now in hiring and increasing the expertise of front-line workers will ultimately distinguish it from such competitors as Amazon, Target, Costco and Walmart, which might sell products but lack a personal touch.

During the quarter, Best Buy launched its exclusive smart TV line in partnership with Amazon. Additional models will hit the market in September and October as the retailer gears up for the holiday shopping season.

Jason Long, founder of the Eye on Retail, said he doesn’t read too much into the dipping stock. Shares are up 33 percent in the last year overall and more than double the last two years.

“It’s just a blip,” he said.

Long believes the fundamental strategy to better integrate services and products will outlast short-term volatility, if the company can pull it off.

“They’re looking for different ways to connect with the consumer,” he said. “They’re going for that long-term relationship with the customer versus the one-time hit.”