The Sheffield-born actor and writer will play the elderly Tom Parfitt, who witnesses a murder on the day he moves into a nursing home, in Remember Me.
Palin, who recently had a small part in World War One drama The Wipers Times, previously appeared in Alan Bleasdale's critically-acclaimed G.B.H. on Channel 4 in 1991.
He said: "This is my first lead role in a TV drama series since G.B.H. It's also a return to Yorkshire, where I was born, brought up and learnt my acting in amateur dramatics.
"I was attracted to Remember Me not only by the northern setting, but also by a good, strong challenging role, something I could really get what remains of my teeth into...I've always loved ghost stories, so playing the lead in one is a very exciting prospect."
The show, which also stars Mark Addy as a policeman, is being filmed in Huddersfield and Scarborough and will be shown later this year.
It is written by Gwyneth Hughes who is best known for her work on crime drama Five Days and The Girl which examined Alfred Hitchcock's obsessive relationship with actress Tippi Hedren.
BBC One controller Charlotte Moore said: "It's a real coup for us that Michael Palin has chosen to make his return to a leading role for the first time in over 20 years on BBC One, and a testament to Gwyneth Hughes' hauntingly brilliant script."