(Adds byline, details on smoke reaching Yosemite Valley and new figures on size)
By Jonathan Allen and Kevin Murphy
Aug 31 (Reuters) - A massive wildfire that has charred the northwest edge of Yosemite National Park in California has sent smoke into a scenic and previously unaffected area, obscuring views of popular landmarks on Saturday for tourists who visited the area.
The smoke from the fire, which broke out two weeks ago, spread to the area during a holiday weekend that in the past years has seen the park fill with visitors.
Shifting winds brought heavy smoke from the so-called Rim Fire to Yosemite Valley, an area famed for its towering granite rock formations, waterfalls and pine forests, according to the park's website and footage from cameras posted on the site that showed smoky conditions.
Yosemite Valley has been open to visitors and largely smoke free in recent weeks, but a park official said smoke began wafting into the area late on Friday. It also reached the Wawona area to the south, the park's website said.
The Rim Fire had charred nearly 223,000 acres (89,000 hectares) by late Saturday. Most of the damage was in the Stanislaus National Forest which spreads out from Yosemite's western edge.
The blaze has blackened about 6 percent of Yosemite's wilder backcountry, said National Park Service Director Jonathan Jarvis.
The Rim Fire was 40 percent contained on Saturday afternoon, up from 35 percent earlier in the day.
"We are moving in the right direction," said Trevor Augustino, spokesman for the U.S. Fire Service at Rim Fire command center.
Flames early on Saturday were heading toward two groves of the park's famed sequoia trees, Jarvis said.
"This is not a catastrophe for Yosemite National Park," he said in a phone interview after surveying the affected areas. "These trees are very old and it's not the first fire they've ever seen."
Firefighters carried out controlled burnings the previous night around the groves to clear away debris from the forest floor that could otherwise fuel a fire to such an intensity that it dangerously licks at the trees' crowns.
Lower-intensity fires, on the other hand, play a vital role in the reproductive cycle of the tough-barked sequoia, many of which bear the scars of past wildfires, by releasing the seeds from their cones and clearing the soil in which they germinate.
The blaze has edged out the 1932 Matilija wildfire in Ventura County to become the fourth-largest California wildfire on record, according to figures from the California Department of Forestry and Fire Protection.
Jarvis estimated that firefighting efforts had cost state and federal agencies about $54 million. He criticized a decline in federal funding for fire-prevention work, including the practice of controlled fires that make a wildfire of this intensity less likely.
More than 5,000 people are working to put out the fire, including firefighters from agencies across California and nearly 700 specially trained California prison inmates.
Some 4 million people visit Yosemite each year, most going during the peak months of June through August. Some 620,000 normally visit the park in August alone, but due to the fire, attendance has dropped.
"It's not super substantial, but it is noticeable," park spokeswoman Kari Cobb said earlier this week about the drop.
Tourism-dependent businesses around the park have bemoaned a slump in visitors at the peak of the late-summer tourist season.
The cause of the fire remains under investigation. (Reporting by Jonathan Allen in New York and Kevin Murphy in Kansas City; Editing by Alex Dobuzinskis and Mohammad Zargham)