A huge, deadly wildfire that burned for weeks and threatened the Yosemite National Park in California has finally been contained.

The Ferguson Fire has burned through nearly 97,000 acres (39,250 hectares) of land to the south-west of the park since 13 July.

More than 3,000 firefighters have battled the blaze. Two have been killed and 19 injured.

Most of Yosemite's tourist areas have now reopened.

Their closure, mainly due to smoke blowing into the park, damaged the local economy during peak tourist season.

The Ferguson Fire is one of several wildfires that have raged across California in recent weeks.

But cooler weather and calmer winds have helped give fire crews the upper hand, officials said.

"The weather is helping the fires to lay down and they [firefighters] are able to get better containment lines around them," said Cal Fire spokeswoman Lynnette Round.

Park authorities tweeted that the Ferguson Fire was at "100% containment".

"Thank you to all of the firefighters for their hard work and dedication," it added.

The centre of the national park has reopened after being shut for three weeks although lingering smoke meant a few main roads remained closed over the weekend.

Park officials urged visitors to exercise caution, warning that sporadic fires still burned within containment lines.

Elsewhere in the state, the Mendocino Complex fire west of Sacramento is now 76% contained, authorities said. They expect to have full containment of it by 1 September.

The fire - the largest in the state's history - has burned about 335,000 acres.

Further north, the Carr Fire, which has killed at least seven people, is now 83% contained according to officials. The fire has destroyed more than 227,000 acres and destroyed more than 1,000 homes.