SAN JOSE — Janet Gray Hayes, who became San Jose’s first female mayor 40 years ago and sparked a late-20th-century women’s movement in elective politics, died Monday about 4:30 p.m. at the Saratoga Retirement Community where she had been living, her daughter, Megan Hayes, said. She was 87.

The former mayor was recovering from pneumonia and a fall, was hospitalized, then had a stroke Sunday morning. She died with her four children at her bedside.

“Janet was a great woman and a great mentor for me,” said Susan Hammer, the second woman mayor of San Jose who took much inspiration from Hayes’ historical place in local, state and national politics. “But more than that, she was a dear friend.”

Hammer said she regularly saw Hayes and took her flowers until about a week ago. “For years she lived a couple of blocks from me until she moved out to Saratoga. I’ll never stop missing her.”

Megan Hayes, the daughter of the former mayor, said, “She was an amazing role model and led an inspired life of public service and was committed to improving the lives of needy people. She’s a completely inspiring person.”

No woman had been elected to lead a U.S. city of more than 500,000 people when Hayes won a runoff victory in November 1974. Hayes at the time proclaimed San Jose the “feminist capital of the world.”

“She was mayor at a time when nobody wanted her,” Susanne Wilson, who served on the San Jose City Council with Hayes, said in a 1987 interview. “None of the good ol’ boys wanted her. And she was successful in building up a perception that women indeed can run a city.”

Hayes’ first attempt at influencing local government came when she was eight months pregnant. Her appeal to the City Council for a school crossing guard in her neighborhood didn’t produce results for more than 16 years.

“Janet was an inspiration for a generation of women and community activists,” said Mayor Chuck Reed, referring to the crossing guard battle that was for her a “simple community issue” but ultimately led to Hayes becoming mayor. “She showed people if they got involved they could make a very big difference.”

Hayes came to San Jose with her husband, Kenneth, a physician, when he took a job at Agnews State Hospital in 1956. The couple met six years earlier as students at the University of Chicago. She was a Phi Beta Kappa graduate of Indiana University, he a medical student from UC Berkeley. She earned a master’s degree in social work and supported his medical studies after they married in 1950.

Kenneth Hayes, an internist, moved on to San Jose Hospital, and she worked as a psychiatric social worker for the Adult and Child Guidance Center in San Jose, rearing their son and three daughters.

In the early 1960s, her League of Women Voters work led her to the presidency of both the San Jose and Bay Area leagues. In 1966 she was named a member of the San Jose Redevelopment Board, and later served as its chair.

Hayes won election to the City Council in 1971, the year Norm Mineta became mayor, and in 1974 decided to try to succeed Mineta when he moved on to Congress. The late Bart Collins, retired chief of detectives in the San Jose Police Department, gave her a scare in a general election race that she won 50.6 percent to 49.3 percent.

Nevertheless, eight years after she had won appointment to a city agency, Hayes had captured the highest elected office in a city of half a million people. San Jose was three years short of 200 years old, and she was the first woman to serve as mayor.

In that era, other big cities couldn’t match San Jose’s distinction in female ascendancy, and her celebrity was immediate. Newspapers accumulated a news file thick with photos of her with such political celebrities as Rosalynn Carter, Dianne Feinstein and Tom Bradley. People Weekly, U.S. News & World Report and Family Circle featured her as a leader of the “feminist capital of the world.” At the 1977 convention of the National Women’s Political Caucus in San Jose, Hayes told delegates, “In sunny Santa Clara Valley, you are in the heartland of women in power.”

Within two elections, eight of the 11 San Jose City Council members and three of the five Santa Clara County supervisors were women, as were the county executive and the president of San Jose State University.

She told the Mercury News in a 1987 interview that when her son asked her to name her biggest source of pride, she replied: “I was proudest of the fact that I could open doors. I had a lot to do with these women getting where they are today.”

But she also influenced the debate over San Jose’s growth during the years of high-tech development. She said she wanted to make San Jose “better before we make it bigger.”

In 1980, she was one of two members of a seven-member City Council — the other was future Mayor Tom McEnery — to oppose binding arbitration for police and firefighters. City leaders later blamed it for soaring pay and benefit costs, and voters limited arbitration with a 2010 ballot measure.

In 1978, Hayes won re-election easily over Councilman Al Garza, but she was four years from a political dead-end. The city charter prevented her from serving more than eight years; she expressed interest in statewide office, but couldn’t find a suitable position. And she was a Democrat — with Republicans Ronald Reagan as president and George Deukmejian as governor.

She still continued to wield influence well into the 1990s, but not without some acrimony. She expressed concerns about traffic and opposed the campaign of her successor, McEnery, to build the San Jose Arena, now called the SAP Center. Hayes opposed the expansion of Mineta San Jose International Airport and the Coyote Valley campus for Cisco.

Her small-town Indiana childhood taught the former Janet Gray Frazee about tough fights. Her father suffered from multiple sclerosis for years before dying of the disease. Her grandmother suffered severe burns that slowly and painfully killed her. “If you think that’s bad,” she once said, “you should hear about my mother’s life. It reads like a Charles Dickens novel.”

In the 1970s, Hayes’ mother, Lucile, and her stepfather, George Hosmer, surprised a burglar at their Indianapolis home who shot and killed Lucile Hosmer.

Hayes worked as office manager for her husband’s medical practice until it was sold in 1991, and continued to volunteer for the League to Save Lake Tahoe, which honored her in 2000. In 2001, she was named one of Indiana’s Trailblazing Women.

The Hayeses’ four children all pursued professional careers, their daughter Lindy as a Santa Clara County public defender; their son, John, as an Analog Devices engineer in Massachusetts; daughter Katherine as director of Tahoe Adaptive Ski School at Alpine Meadows; and daughter Megan as a Colorado attorney living in Wyoming.

Kenneth Hayes was 92 when he died in May 2013.

Through all her success, Hammer says Hayes was an inspirational leader without airs.

“Her personality was terrific. She was straightforward. What you saw was what you got,” Hammer said. “She was not overly impressed with her position and she and Ken were very generous about opening their home to organizations and charities in need. Whether greeting a president coming through town or playing tennis on a public court, she had a strong sense of who she was.”

In her 72nd year, around the turn of the century, Hayes still could rely on a sense of humor. When asked in a Mercury News series about the 21st century, she said, “If there is one thing I know for sure, it is that I know nothing for sure.”

Staff writers Scott Herhold, David Early and Julia Prodis Sulek contributed to this report.