Sherwood Schwartz, writer-creator of TV favorites “Gilligan’s Island” and “The Brady Bunch,” died Tuesday in Los Angeles. He was 94 and was being treated at Cedars-Sinai Medical Center for an intestinal infection and underwent several surgeries.

Neither “Gilligan’s Island” nor “The Brady Brunch” pleased the critics, but they ran for decades in syndication after their initial network runs and reverberated in popular culture as few such series did, inspiring parodies, spinoffs and standup comedy jokes. The catchy theme songs for the shows, with lyrics penned by Schwartz, only added to their appeal and longevity.

Schwartz dreamed up “Gilligan’s Island” in 1964. It was a Robinson Crusoe story about seven disparate travelers who are marooned on a deserted Pacific island after their small boat wrecks in a storm.

Calling “Gilligan’s Island” a “family,” Tina Louise, who played movie star Ginger Grant on the show, tweeted that “Sherwood Schwartz brought laughter and comfort to millions of people.” In her Twitter post she added, “He will be in our hearts forever.”

TV critics hooted at “Gilligan’s Island” as gag-ridden corn. Audiences adored its sometimes-crude comedy. Schwartz insisted that the show had social meaning along with the laughs: “I knew that by assembling seven different people and forcing them to live together, the show would have great philosophical implications.”

He argued that his sitcoms didn’t rely on cheap laughs. “I think writers have become hypnotized by the number of jokes on the page at the expense of character,” Schwartz said in a 2000 Associated Press interview.

“When you say the name Gilligan, you know who that is. If a show is good, if it’s written well, you should be able to erase the names of the characters saying the lines and still be able to know who said it. If you can’t do that, the show will fail.”

“Gilligan’s Island” ran on CBS from 1964-67 and later years spawned three high-rated TV movies. A children’s cartoon, “The New Adventures of Gilligan,” appeared on ABC from 1974-77, and in 2004, Schwartz had a hand in producing a TBS reality show called “The Real Gilligan’s Island.”

The name of the boat on “Gilligan’s Island” — the S.S. Minnow — was a bit of TV inside humor: It was named for Newton Minow, who as Federal Communications Commission chief in the early 1960s had become famous for proclaiming television “a vast wasteland.”

Minow took the gibe in good humor, saying later that he had a friendly correspondence with Schwartz.

TV writers usually looked upon “The Brady Bunch” as a sugarcoated view of American family life. But during the 1970s, when the nation was rocked by social turmoil, audiences seemed comforted by watching an attractive, well-scrubbed family engaged in trivial pursuits.

Schwartz claimed in 1995 that his creation had social significance because “it dealt with real emotional problems: the difficulty of being the middle girl; a boy being too short when he wants to be taller; going to the prom with zits on your face.”

The series ran 1969-74 but had an extraordinary afterlife. It was followed by three one-season spinoffs: “The Brady Bunch Hour” (1977), “The Brady Brides” (1981) and “The Bradys” (1990). “The Brady Bunch Movie,” a feature film starring Shelley Long and Gary Cole that lampooned the series, was a surprise box office hit in 1995. It was followed the next year by a less successful “A Very Brady Sequel.”

Sherwood Schwartz was born in Passaic, N.J., grew up in Brooklyn and went to NYU. He moved to Southern California to pursue an advanced degree in biology at USC but gave up a career in medical science when his brother, Al, who was working for Bob Hope’s radio show, got him a job writing jokes for the comedian in 1939.

“Bob liked my jokes, used them on his show and got big laughs. Then he asked me to join his writing staff,” Schwartz said during an appearance in March 2008, when he received a star on the Hollywood Walk of Fame. “I was faced with a major decision — writing comedy or starving to death while I cured those diseases. I made a quick career change.”

During the 1940s he wrote for radio shows including “The Adventures of Ozzie and Harriet.”

The brothers started as a writing team in 1950s TV, working on the long-running “The Red Skelton Show.” Schwartz made clear in his 1994 book “Inside Gilligan’s Island” that he did not get along with Skelton.

“Sherwood continued to produce all the way up into his 90s,” said Douglas Schwartz, the son of Al Schwartz. Sherwood Schwartz was working on a bigscreen version of “Gilligan’s Island,” his nephew said. Douglas Schwartz, who created the series “Baywatch,” called his uncle a longtime mentor and caring “second father” who helped guide him successfully through show business.

The book “Brady, Brady, Brady: The Complete Story of The Brady Bunch as Told by the Father/Son Team Who Really Know,” by Schwartz and son Lloyd, was published last year.

Schwartz wrote a message to be released posthumously. The scenario had him facing his maker at the pearly gates. In the message he mentioned his pride over his own achievements and those of his family. With characteristic humor, he wrote, “Writing isn’t a profession; it’s a disease. And it’s accompanied by a disease that’s even worse, rewriting.”

Schwartz’s survivors his wife, Mildred; three sons, TV writer-producer Lloyd, screenwriter Ross and Donald, a doctor; a daughter, TV writer-actress Hope Juber; eight grandchildren; and four great-grandchildren.

(Associated Press contributed to this report.)