U.S.-listed exchange-traded funds attracted inflows of $188.4 billion in 2013, just shy of 2012’s record $190.1 billion influx, according to fund research company Morningstar Inc.

The best gainers were equity ETFs, which saw inflows of $97.7 billion last year. That’s a 20.4 percent organic growth rate over the prior year. The next-largest categories by total assets were international equity and sector equity ETFs, which had inflows of $56.5 billion and $44.7 billion at year-end, respectively.

According to Morningstar, the combination of strong inflows and market appreciation enabled ETF assets to hit $1.7 trillion by the end of 2013.

Morningstar also said that 2013 was the first time any ETF category group had outflows for a calendar year––the two categories achieving that dubious distinction were commodities ETFs (outflows of $29.5 billion) and municipal-bond ETFs (outflows of $253 million).

Among other highlights (and lowlights), the SPDR S&P 500 ETF (SPY), the largest ETF, attracted the greatest inflows in 2013, bringing total assets to $174.8 billion. But the fund is losing market share to iShares Core S&P 500 ETF (IVV) and Vanguard S&P 500 ETF (VOO).

And the SPDR Gold Shares Trust (GLD) lost 27.3 percent last year, its worst annual return since it lost 32.6 percent in 1981. Due to the fund’s poor performance, it saw outflows of $25.1 billion––and assets fell by more than half––in 2013.

Meanwhile, Vanguard led all firms with ETF inflows of $55.1 billion and continues to gain market share. Other ETF providers that made market share gains last year were  PowerShares, WisdomTree, Guggenheim, First Trust, Schwab, ALPS, and FlexShares.