Ed Lee, a lawyer and affordable housing advocate who was the first Asian-American to be elected mayor of San Francisco, died early Tuesday in a hospital there after collapsing. He was 65 and in the midst of his second full term.

The cause was not immediately announced by his office. In a statement, the office said he died at 1:11 a.m. at Zuckerberg San Francisco General Hospital.

Mr. Lee was in critical condition when he arrived at the hospital by ambulance shortly after 10 p.m. on Monday, according to Dr. Susan P. Ehrlich, the hospital’s chief executive. Mr. Lee’s family asked that further medical details not be released, she said.

Local news accounts said Mr. Lee had collapsed while shopping at a supermarket.

London Breed, the president of the board of supervisors, was named acting mayor. Dennis Herrera, the city’s attorney, said the board can decide whether it wants to choose a replacement mayor before June, when an election will determine who will finish out Mr. Lee’s term. He was re-elected in 2015.