Television writer David Croft, who helped create much-loved British sitcoms such as “Dad’s Army” and “Are You Being Served?,” died Tuesday, Sept. 27, at his holiday home in Portugal. He was 89.

Croft’s family said in a statement that he “died peacefully in his sleep,” but did not give a cause.

The son of actors, Croft served with the Royal Artillery during WWII before starting a showbiz career, eventually moving into TV as a producer, director and writer.

Several of his comedies had military settings, including “It Ain’t Half Hot Mum” — set in wartime India and Burma — and “Dad’s Army,” about a hapless WWII Home Guard unit.

Co-created with Jimmy Perry, “Dad’s Army” is considered a comedy classic, and it’s still frequently rerun more than 40 years after its debut.

Croft and Perry had another long-running hit with the 1980s sitcom “Hi-de-Hi!,” set in a 1950s holiday camp.

With Jeremy Lloyd, Croft wrote several series in the 1970s and ’80s, including “‘Allo ‘Allo!” — set in the unlikely comic environment of Nazi-occupied France — and the perennially popular department-store sitcom “Are You Being Served?”

The shows drew viewers in the millions with their mix of memorable characters, nostalgic settings, catch phrases and double entendres.

Former BBC head of comedy Jon Plowman said Croft was “quite simply a genius who invented a whole genre of comedy that was all his own — mostly from his own experience. He wrote so much of the great comedy from the last 30 or 40 years, always impeccably cast with an ensemble of great character actors.”

In 1978, Croft was named an Officer of the Order of the British Empire by Queen Elizabeth II for services to television.

He is survived by his wife and children.