JOHANNESBURG — Two of Africa’s leading economies said Tuesday they have emerged from recession.

South Africa and Nigeria released figures showing economic growth in the second quarter of this year.

South Africa’s government said the gross domestic product grew by 2.5 percent in the quarter, helped by the agriculture, forestry and fishing sectors. The country announced in June it had entered recession.

Nigeria’s government said its GDP grew by .55 percent in the quarter, aided by growing oil production. The West African power has struggled to diversify its economy beyond oil and has suffered from militant attacks on oil facilities in the oil-rich Niger Delta.

Nigeria had been in recession since last year, with five quarters of negative growth.

“Unfortunately, the Nigerian government has not taken advantage of the crisis to make tough decisions that will forestall such a recession in the short and long term,” analyst SBM Intelligence said in a statement. “The moment oil prices take a big enough hit again, Nigeria will be headed back to a recession.”

On Twitter, President Muhammadu Buhari said that “until coming out of recession translates into meaningful improvement in people’s lives, our work cannot be said to be done.”