With gains from divestitures and surprising growth from a once-troubled electronics unit, 3M Co. saw second-quarter profits grow more than 22 percent, prompting officials to boost its guidance for the year.

Still, its results missed expectations, and the company's stock lost 5 percent of its value on Tuesday.

The Maplewood-based maker of Scotch tape, Post-it notes, hearing protection and cellphone films reported second-quarter sales rose 1.9 percent to $7.81 billion, slightly missing expectations.

Profits jumped to $1.58 billion, or $2.58 a share, compared with $1.29 billion, or $2.08 a share, in the same quarter a year ago. The earnings for the quarter ended June 30 included a 33 cents benefit from divested divisions. Excluding the divestiture gains, adjusted profits were $2.25 per share, which was below the average $2.54 per share analysts expected.

Regardless, 3M officials praised the results.

"Our team posted another quarter of strong and broad-based organic growth," CEO Inge Thulin told analysts on a conference call. "We also continued to deliver premium margins and returns, while accelerating investments to support growth and strengthen the portfolio, which is part of our playbook to build an even stronger and more competitive 3M."

During the quarter, four of 3M's five businesses posted gains. Only Safety & Graphics showed a slight sales decline. Excluding foreign currency exchange rates, all units grew in the quarter ended June 30.

3M's once-troubled Electronics and Energy business saw some of the largest sales and profit gains during the quarter. The unit's profits before taxes surged 38 percent and sales jumped 7.5 percent to $1.2 billion.

3M's largest business, Industrial, saw sales rise 2.5 percent to $2.7 billion amid rising demand for automotive, aerospace and industrial adhesives. The unit, however, saw profits before taxes fall 15 percent to $523 million amid divestitures, unfavorable currency exchanges and growth investments.

Across all divisions, 3M had the strongest sales growth in Asia, followed by Latin America/Canada, and then the United States. Sales fell 3.6 percent in Europe, the Middle East and Africa.

During the analysts' call, Thulin and Chief Financial Officer Nick Gangestad noted that the global economy had largely stabilized from last year and that 3M benefited from its intense investments in growth, factory footprint consolidations and the divesting of noncore businesses. They also said the second quarter benefited from temporary price declines across several lines that helped drive volume.

Analysts questioned those price declines, saying they worried that price drops could become a habit that is not traditionally associated with 3M.

Other analysts noted that massive industrial suppliers such as Grainger Industrial had recently reduced its pricing in response to the threat of Amazon and other factors.

Thulin and Gangestad said 3M was not negatively affected by Amazon's growth. Thulin said that online sales represented only about 2 to 3 percent of 3M's overall business. Gangestad added that 3M expects to increase several prices later this year, especially for 3M Industrial.

Still, the idea that 3M potentially sacrificed some pricing last quarter to gain market share rattled investors.

3M's stock fell 5 percent to $199.39 on Tuesday. 3M's stock traded near an all-time high for weeks. It reached a 52-week high of $214.57 last month.

"Investors did not like 3M's discussion about investing in pricing to gain market share. This company has historically been viewed as an innovator with the pricing power to take or hold market share without lowering price," said Edward Jones equity analyst Matt Arnold. "We view the impact of this decision as small overall and not necessarily a departure in strategy."

3M now expects local-currency sales to grow 3 to 5 percent. That's up from the earlier forecast for 2 to 5 percent. Earnings are now expected to reach $8.80 to $9.05 a share, up from the prior forecast of $8.70 to $9.05 per share. If achieved it will represent an 8 to 11 percent increase over 2016 results.

The brighter outlook belies several headwinds from the last two years as 3M suffered problems with lackluster demand for consumer electronics, slowing health care sales, a high U.S. dollar and weakened energy and industrial sectors. The combination strangled sales growth and drove 3M into harder efficiency, cost cutting and business right-sizing moves.

In two years, it sold seven "noncore" businesses; planned the purchase of two massive worker-safety product firms; invested in a new global computer system; and reduced underutilized factory and distribution space to maximize margins and profits. Thulin noted the work is paying off.

During the second quarter, 3M realized net divestiture gains of $451 million and spent $178 million on accelerated growth programs, productivity and portfolio actions.

Even with the changes, CFRA research analyst Jim Corridore said he still rates 3M a "hold." 3M missed his company's profit expectation for the second quarter. For the future, "we see an improving revenue environment, but see shares at trading near fair value."