Composer Fred Steiner, who wrote the themes for “Perry Mason” and “Rocky and Bullwinkle” and who later became a respected film-music historian and musicologist, died of natural causes Thursday at his home in Ajijic, Mexico. He was 88.

Steiner was Oscar nominated for his contributions to Quincy Jones’ 1985 score for “The Color Purple.” He also scored, on his own, a handful of features including “Man From Del Rio,” “Time Limit,” “The St. Valentine’s Day Massacre” and “The Sea Gypsies.”

But it was in television where Steiner made an enduring mark, with memorable scores for seven early-1960s episodes of “The Twilight Zone” and a dozen scores for the original “Star Trek” including such now-classic episodes as “Charlie X,” “The Corbomite Maneuver” and “Balance of Terror.”

His TV work — which spanned the 1950s through the 1990s — also included dozens of episodes of “Gunsmoke,” “Have Gun — Will Travel,” “Rawhide,” “Daniel Boone,” “The Wild Wild West,” “The Virginian,” “The Guns of Will Sonnett,” “Hogan’s Heroes,” “Mannix,” “Hawaii Five-O,” “Dynasty,” “Amazing Stories” and “Star Trek: The Next Generation.” He also penned the themes for TV’s “Navy Log” and “Boots and Saddles.”

Steiner’s most famous piece is probably the 1957 theme for the long-running lawyer series “Perry Mason,” although his fun music for the 1961 cartoon series “Rocky and His Friends” (later, in primetime, “The Bullwinkle Show”) is an equal favorite of baby boomers; Steiner’s music included the Broadway-style “Bullwinkle Show” theme and a sendup of silent-movie-music cliches for “Dudley Do-Right of the Mounties.”

His facility with animation also resulted in the theme for “Beany and Cecil” plus several scores for “Tiny Toon Adventures” in the early 1990s. His TV-movie scores included “River of Gold,” “Family Flight,” “Night Terror,” “Heat Wave” and “Blood Feud.”

Steiner was well-known in the industry for assisting composer colleagues, often at the last minute and without screen credit. He adapted or wrote sequences for Alfred Newman on “The Greatest Story Ever Told,” for Jerry Goldsmith on “Star Trek: The Motion Picture” and for Alex North on “Prizzi’s Honor” and the TV remake of “Death of a Salesman.”

Steiner’s 1974 essay on Bernard Herrmann’s “Psycho” was the earliest known musicological analysis of a film score, and he earned a Ph.D. in 1981 after writing a dissertation on the life and music of Alfred Newman — believed to be the first about a film composer to result in a doctorate in musicology in America.

Steiner was one of the founders of the Society for the Preservation of Film Music, now known as the Film Music Society, and he served on its board for many years. He also conducted several albums of classic film music by Max Steiner (no relation), Alfred Newman, Bernard Herrmann and the “Star Trek” composers.

He was born in New York, the son of film composer George Steiner; began music studies at the age of 6; and graduated from the Oberlin Conservatory of Music at the age of 20. Within months of his graduation he was composing and arranging for radio broadcasts including the popular drama “This Is Your FBI.”

He moved to Hollywood in 1947 and spent much of the 1950s writing for CBS’ live radio and TV broadcasts, including the celebrated “Playhouse 90.” He lived in Mexico City from 1958-60, scoring documentaries and recording Latin-American music.

Survivors include his wife of 64 years, Shirley; two daughters, singer-songwriter Wendy Waldman and Jillian Sandrock; a sister; two grandchildren; and two great-grandchildren.