Metals and mining stocks were thrown off gear after prices of metals crashed from their peaks in 2011 and brought the global commodity markets to a grinding halt. Now mining stocks are showing signs of life. Prices of key base metals such as iron ore, copper, zinc, lead, nickel, and aluminum are on fire, fueling investors' optimism that the worst is behind the mining industry.

The excitement is evident in the stock market: Some of the world's largest metals and mining stocks, including Vale, Glencore, and Freeport McMoRan (FCX 0.83%), have clocked triple-digit percentage gains in a couple of years, while shares of mining giants such as BHP Billiton (BHP 2.55%), Rio Tinto (RIO 1.66%), and Southern Copper have gained double-digit percentages during the period. Precious-metal stocks haven't disappointed, either, with leading gold miner Barrick Gold (GOLD 1.33%) and streaming and royalty giant Wheaton Precious Metals (NYSE: WPM) logging 60%-80% returns since the beginning of 2016.

The verdict is clear: Now could be a great time to consider some metals and mining stocks. However, given the recent rally in most mining stocks, it's important that you pick your stocks carefully and go for miners that can make the most of a commodity up cycle. Three stocks look particularly compelling right now -- diversified mining giants BHP Billiton and Rio Tinto, and gold and silver play Wheaton Precious Metals.

One mining stock, exposure to many metals

BHP Billiton is hiring.

This news alone should drive investor interest in the mining stock, given how layoffs had become a new normal in the mining industry. Though 120 is a small number, BHP is looking to hire that many workers at its primary mine, Olympic Dam in Australia.

A person holds chunks of coal in his hands.

With metal markets improving, it's time to consider buying metals and mining stocks. Image source: Getty Images.

Copper's usage in battery-operated electric vehicles is sending the metal's demand and prices through the roof. Freeport McMoran, the world's second largest copper producer, even foresees deficit in the copper market in the long run, as there are few new greenfield projects and the existing ones have lead times as long as seven to 10 years.

Olympic Dam is among the world's largest deposits of copper and uranium. BHP aims to scale up copper production from the mine to 230 kilotonnes per annum (ktpa) by fiscal 2021 from 166 ktpa in fiscal 2017. The company has the capacity to scale up to 450-500 ktpa in the long run.

But owning BHP doesn't mean investing in just copper. BHP is one of the most diversified metals and mining companies, with exposure to iron ore, metallurgical coal (used in steel), copper, nickel, and zinc, among other metals. What's more, BHP also owns potash assets and derived 20% of its earnings before interest, tax, depreciation, and amortization (EBITDA) from oil and gas in fiscal 2017. The miner is currently rejigging its oil business to exit U.S. onshore oil and gas assets and focuson conventional operations, primarily in the Gulf of Mexico and Australia.

Financially, BHP is on its best footing since 2012, having generated free cash flow worth $12.2 billion in the trailing 12 months and bringing its debt-to-equity ratio down to a manageable 50%. Management is also targeting a "minimum" payout ratio of 50%, which should boost BHP's allure as a dividend stock. Overall, a leaner product portfolio and a cleaner balance sheet make BHP an interesting metals and mining play.

This stock's investing in hot metals like lithium

Much like BHP, Rio Tinto's primary product is iron ore, but the mining stock stands out for three big reasons: diversion away from coal, exposure to aluminum, and growing interest in hot metals like lithium. Here's what Rio's portfolio for the first half of the year looks like by commodity and geography.

Pie charts showing Rio Tinto's revenue by commodity and geography.

Image source: Rip Tinto.

Rio Tinto's boldest move, perhaps, is exiting nearly all its coal business. Instead, the metals and mining giant is renewing focus on red-hot metals such as nickel and lithium, both of which have taken off lately thanks to a pickup in demand for electric-vehicle batteries. For instance, Rio just joined the race for fertilizer manufacturer PotashCorp's 32% stake in the world's largest lithium manufacturer, Chile's Sociedad Quimica y Minera de Chile, which could be worth $4 billion.

Meanwhile, Rio is also expanding its base metal production. Two of its high-potential projects, Amrun alumina and Oyu Tolgoi copper mines, are on track to start commercial production within a couple of years and are expected to generate internal rate of returns over20%.

Another encouraging point about Rio is its focus on costs. After slashing its unit costs by almost 40% in the past five years, Rio is aiming for additional cost savings of $2 billion by fiscal 2019. By 2021, Rio expects its cost-reduction initiatives to generate an additional $5 billion of cumulative free cash flow. The miner has been solidly FCF positive since 2013.

Add it all up, and Rio looks well poised to take advantage of recovering commodity markets.

Get exposure to precious metals with a non-mining stock

Wheaton Precious Metals isn't a traditional gold and silver miner, yet it offers investors the same exposure to gold and silver as any mining company.

Wheaton finances mining companies up front to support their growth projects, and in return, it bags the right to buy streams of precious metals, usually, over the life of mine, at discounted prices. So Wheaton can not only avoid the huge mining costs but also procure metals at significantly low costs. For perspective, Wheaton's cost price for gold and silver has averaged $400 and $4 per ounce, and its operating margin was 35% for the trailing 12 months. For mining investors, this makes Wheaton a relatively safer way to bet on precious metals.

Gold and silver bars.

Wheaton Precious Metals offers strong exposure to both, gold and silver prices.Image source: Getty Images.

From its original focus on silver, Wheaton is on its way to becoming a 55% silver and 45% gold company, thanks to its agreement with Vale, which entitles it to 75% of the gold produced from its Salobo mine.

As of now, Wheaton has streaming agreements with 20 operating and eight developing mines, with leading gold mining companies including Barrick. During the recent third-quarter earnings call, President and CEO Randy Smallwood revealed that the company is pursuing several "high-quality accretive opportunities." Any new deal should act as a positive trigger for Wheaton Precious Metals stock, which is already the leader in the precious metals streaming and royalty space and has the strongest cash-flow track record among its peers.

The bottom line: Whether it's base metals, minerals, or precious metals, it's time to pay attention to metals and mining stocks.