William Windom, who won an Emmy Award playing an Everyman drawn from the pages of James Thurber but who may be best remembered for his roles on “Star Trek” and “Murder, She Wrote,” died on Thursday at his home in Woodacre, Calif., north of San Francisco. He was 88.

The cause was congestive heart failure, said his wife, Patricia.

Mr. Windom won the Emmy for best actor in a comedy series in 1970 for his performance in “My World and Welcome to It,” a whimsical TV show based on Thurber’s humorous essays and fantastic cartoons. He subsequently toured the country with a solo show based on Thurber’s works.

But filmgoers and television viewers may be more likely to associate him with roles that, though also fanciful, had a distinctly darker tone. He teamed up with Rod Serling on episodes of both “The Twilight Zone” (“Five Characters in Search of an Exit” in 1961 and “Miniature” in 1963) and “Night Gallery”; played the president in “Escape From the Planet of the Apes”; and had a memorable role in an early episode of “Star Trek.” He was also a guest star on “The Rookies,” “The Streets of San Francisco” and dozens of other television shows.

Not until 1985 did Mr. Windom find another role that drew on his avuncular side with such success: he appeared in more than 50 episodes of “Murder, She Wrote” as the leading physician of Cabot Cove, Me., and a close friend of Jessica Fletcher, the lead character played by Angela Lansbury.