Origin of Cliffhanger

An episode that ends in a desperate situation...any story, play, etc., in which suspense is a main concern. OED

Illustration for A Pair of Blue Eyes (1872)  see here

In The Art of Fiction (1991), David Lodge names the Thomas Hardy novel A Pair of Blue Eyes (1873) as the first example of a literal cliffhanger in popular fiction. 

Lodge was referring to Chapters XXI-XXII, in which a leading character, Henry Knight, is literally left dangling from a cliff  

"a classic scene of suspense that was, as far as I know, entirely invented. The word [suspense] derives from the Latin word meaning 'to hang', and there could hardly be a situation more productive of suspense than of a man clinging by his finger-tips to the face of a cliff unable to climb to safety - hence the generic term, 'cliff-hanger'".

Based on real events?

Lodge later clarified that Hardy had popularized rather than invented the term 'cliffhanger'. The cliffhanger scene was inspired by his visits to Beeny Cliff on the Cornish coast. 

The novel has many autobiographical elements. He had been awestruck by the local geography, which he explored while courting his first wife, Emma Gifford. 

The literary biographer Carl J. Webber also cites a specific incident in 1870 when Emma dropped an earring on the cliff edge and Hardy (foolishly) tried to retrieve it in the rain.