Two people in San Francisco — a man in his 90s and a woman in her 40s — have tested positive for the coronavirus, city officials said Thursday.

The diagnoses represent the first reported cases of the virus in San Francisco. Several coronavirus patients have been transported to and treated at San Francisco hospitals, but those patients were not city residents.

Both patients, whose names are not being released to protect their privacy, were tested for the virus Wednesday after presenting pneumonia-like symptoms linked to the virus in accordance with testing guidelines laid out by the Centers for Disease Control and Prevention.

Both patients are receiving treatment inside of isolated rooms at two separate San Francisco hospitals. Officials at Zuckerberg San Francisco General Hospital notified staff members that the hospital had at least one patient who had tested positive for the virus. The notice said that any staff members who comes into contact with or provides care to the patient would be “contacted about monitoring.”

“We have been planning for this for weeks, and so we are prepared as a city,” said Mayor London Breed. Breed declared a state of emergency for San Francisco on Feb. 25 in an effort to ramp up the city’s efforts to prepare for and confront local cases. The city activated its emergency operations center to focus its response to the virus in late January.

The man, who is in serious condition, suffered from underlying health issues. The woman is in fair condition, said Dr. Grant Colfax, director of the city’s health department.

Neither patient had a history of travel to places with confirmed coronavirus cases, nor did they knowingly come into contact with anyone diagnosed with the disease. City officials said the cases are likely indicative of a community spread of coronavirus.

“All appropriate precautions for the patient, visitors and hospital staff are being taken,” Colfax said.

San Francisco began testing for coronavirus locally — rather than sending test kits to the CDC in Atlanta for analysis — on Monday, allowing health officials to get results within one to two days, rather than a week.

San Francisco officials, alongside health and emergency management personnel at the state and federal levels, are also closely monitoring the condition of travelers aboard the Grand Princess cruise ship, which is currently at sea, but could anchor at San Francisco.

There are no confirmed cases of coronavirus aboard the ship, but Mary Ellen Carroll, director of the city’s Department of Emergency Management, said the CDC was administering tests Thursday, with results expected early Friday.

There are nearly 2,400 passengers aboard the ship and over 1,000 crew members. Of those, 35 people have shown flu-like symptoms at some point during the ship’s 15-day trip, but but some had recovered, Carroll said.

The ship was 100 nautical miles off shore, northwest of Santa Cruz as of Thursday afternoon, according to Vessel Finder, which tracks ship locations.

If coronavirus cases are confirmed aboard the ship, the CDC and Coast Guard would determine where to send the vessel.

Gov. Gavin Newsom declared a state of emergency for California over the virus on Wednesday in the wake of the death of a 71-year-old Placer County man, who had taken an earlier cruise on the Grand Princess from San Francisco to Mexico, where he likely contracted the virus.

The man — and another former passenger from Sonoma County — did not get diagnosed with COVID-19, the illness caused by the coronavirus, until Monday, 10 days after they left the ship.

Carroll said the city was working to contact any San Francisco residents who might have been on the same trip as the man who died.

Dominic Fracassa is a San Francisco Chronicle staff writer. Email: dfracassa@sfchronicle.com Twitter: @dominicfracassa