The stocks of Minnesota companies performed better than the broader market in 2016, a turnaround from 2015 when most were a disappointment for investors.

Major U.S. stock indexes, which ended flat in 2015 and were in negative territory for the first 10 weeks of this year, closed 2016 with solid gains. The Dow Jones industrials finished up 13.4 percent, its best performance since 2013. The broader-market S&P 500 index finished up 9.5 percent and tech-heavy Nasdaq was up 7.5 percent.

The Piper Jaffray Minnesota index, a measure of companies headquartered in the state, finished the year up 16 percent at 645.68. It closed 2014 at 674.87, then fell 17.5 percent to finish 2015 at 556.35.

Shares in about 50 of the approximately 80 publicly traded companies based in Minnesota finished 2016 at a higher price than they did a year ago. Only 20 Minnesota companies saw stock price gains for the full year of 2015.

Executives and investors of one of the state’s best-known companies, Target Corp., spent ­Friday watching to see whether its shares would finish up or down for the year.

Target’s share price on Thursday closed at $72.62, a penny above its close on the last day of 2015. It rose to $72.90 in the opening minutes of trading Friday, but drifted lower and, shortly before noon, fell below the 2015 close of $71.61 and kept drifting lower to close at $71.23 — a half-percent decrease for the year.

On the last day of 2015, shares in Xcel Energy Inc. traded right around their year-earlier threshold before closing down 1 cent for the day and year. Xcel shares climbed 13 percent in 2016.

The two Minnesota companies among the 30 firms composing the Dow Jones industrials average helped power its 2016 gain. Shares in 3M Co. rose 19 percent this year, while those in UnitedHealth Group jumped 36 percent.

The big rise by UnitedHealth, the nation’s largest health insurer, extended its lead over 3M and other companies in market capitalization. UnitedHealth took the lead for the first time in 2015, a symbolic shift that ended decades in which the manufacturing giant was the state’s most valuable firm. UnitedHealth’s market cap is now $152 billion while 3M’s is now just more than $107 billion.

The best-performing stock in Minnesota this year was CyberOptics Corp., the Golden Valley-based maker of sensors and measuring equipment used by makers of semiconductors and other precision devices. Its shares more than tripled as sales bolted upward following its introduction of a device that makes three-dimensional scans of physical objects at a faster speed than laser-based scanners. The product positioned the company for further growth in coming years.

Two of the top performers in Minnesota, Capella Education Co. and Piper Jaffray Cos., benefited from the post-Election Day gains that became known as the Trump rally. Shares in Capella, a provider of online education, were up about 30 percent for the year up to the day of the election and finished the year up 90 percent on perceptions that the Trump administration will ease regulations on for-profit education firms. Piper Jaffray, a brokerage firm, was one of many financial companies whose shares rose, also on perceptions that Trump will reduce costs and regulations on that industry.

The worst-performing Minnesota stock this year was Sunshine Heart Inc., an early stage medical device company in Eden Prairie that is focused on treatments for heart failure. Its shares fell 74 percent in 2016. Its investors will decide on Jan. 9 whether to allow a capital infusion through the issuance of preferred shares to an outside investment group.