What happened

Shares of B2Gold (BTG -6.23%) rallied more than 11% by 12:45 p.m. EDT on Wednesday. Driving up the gold mining stock was its expectation-beating second-quarter results.

So what

B2Gold generated $52 million, or $0.05 per share, of adjusted net income during the second quarter, which came in $0.02 per share ahead of the consensus estimate. Driving that better-than-expected result was record quarterly gold production of 246,020 ounces. That was 8% above its budget and 2% ahead of last year's second quarter due to strong results across the company's operations.

Gold nuggets on top of cash.

Image source: Getty Images.

The gold miner also outperformed its cost expectations. All-in sustaining costs (AISC) came in 10% below budget at $807 an ounce, due in part to the fact that it spread them out over the higher volumes.

Expenses should further decline in the coming years as a result of two strategic initiatives the company recently approved. First, it plans to build a large-scale solar project to support its Fekola mine in Mali, which should help reduce its processing costs by 7%.

The company also agreed to join forces with Calibre, another miner in Nicaragua. B2Gold will sell its El Limon and La Libertad gold mines as well as other assets in that country for $100 million in cash and stock, giving it a 31% stake in that miner. That deal will not only boost B2Gold's balance sheet but also help reduce its costs.

Now what

B2Gold benefited from its ability to deliver record gold production during the quarter while also keeping costs down. Meanwhile, the company took steps to further reduce expenses by approving a solar energy project and combining its Nicaraguan assets with Calibre. Those factors set it up to deliver improving profitability in the coming years.