'It's about old men who get it wrong when they have power and influence – and then get into a mess. That's the reason I'm doing this opera." Alexander Goehr is telling me about Promised End, his new piece based on Shakespeare's King Lear. "As an incipient old man myself, that's what interested me about the story. I mean, I can't do Romeo and Juliet now – I'm past that stage."

At 78, Alexander "Sandy" Goehr is one of the linchpins of the British musical establishment. He was professor of music at Cambridge University for nearly a quarter of a century, where he taught the brightest compositional talents of two generations (George Benjamin and Thomas Adès among them); as a student, he was one of the Manchester School of composers, along with Harrison Birtwistle and Peter Maxwell Davies, who brought British musical life kicking and screaming into the modern age, and he's one of the most provocative and searching musical intellects anywhere. Not that he thanks me for reminding him of his establishment credentials. "It's all bullshit," he says with a wry smile, somehow managing to make a cuss word sound cultured with his deep, resonant tones. "Nobody understood that I was a complete outsider at Cambridge. I haven't even got a degree, let alone a doctorate – and I only got the job back in 1976 because the place was so clapped out they had to appoint a sort of academic doctor to sort it out."

Cambridge is partly responsible for the genesis of Promised End, and for Goehr's turning to Lear for inspiration. "The short answer to why I wrote this piece is that I did it to overcome depression. I'd been kicked out of the university in 1999, because I had reached retirement age. And then the phone stopped ringing, as if nobody wanted anything from me any more. It was a bad time. And I thought, 'Perhaps my music has had its day.' It was a time when styles were changing, when there was an emerging anti-intellectualism, and I was connected with a supposed intellectualism, for better or for worse. We're simple fellows, we composers. We want to get our pieces played, and to be asked to do nice things. And those things weren't happening to me or my music. So I was depressed."

Goehr reached a nadir of disappointment in 2002, his 70th birthday year. "I thought somebody might take some notice then. But nobody did – not that I wanted trumpets blaring on my behalf or anything: I just felt then that my time was up." But he dealt with his depression constructively, as he has done in the past. "I'm loth to think that whatever is the reason for my depression is somebody else's fault, or that it's a conspiracy. I generally think it's my fault, something I've said, somebody I've offended" – Goehr has never shirked from telling people what he really feels, an honesty that hasn't always helped to grease the wheels of the classical music industry – "or something I've written that is not good. I search for that reason. And out of that process, in this case, came this piece."

The catalyst for the Lear opera was a dream. "I take dreams very seriously. Many of my pieces begin in dreams." Goehr was researching Greek tragedy for a new stage work, "but I dreamt not the Greeks, but King Lear. And Lear staged as a Japanese Noh play! I woke up and thought: 'Why this?' I was in Jerusalem at the time, and I hadn't read or seen the Shakespeare in years, so I bought a secondhand copy. From the beginning I was very attracted to the idea [of an opera based on the play], but I thought it was terribly pretentious. Imagine the conversation between a couple of composers: 'What are you writing at the moment?' 'Oh, a trio for flute and strings.' 'Me? Nothing much – I'm writing an opera on King Lear …'"

Goehr's solution to the problem of potential pretension was to work with Frank Kermode, the Shakespeare scholar and fellow Cambridge professor. "There was a very big initial problem. The words." It's impossible to set Shakespeare's entire text as an opera – what lasts four hours in the theatre would last about eight in the opera house – but Goehr wanted to keep Shakespeare's words rather than mess about with them. "Thomas Adès was working on his opera of The Tempest at the time we were working on Lear, and Frank and I saw it. I disliked the libretto [by Meredith Oakes] particularly, because, although it maintained the drama of the whole play, it reduced the greatest poetry in the world to doggerel." Kermode instead came up with a shortened version of Lear, and then a libretto using only Shakespeare's words, which Goehr fashioned into the "24 preludes" of Promised End (the title comes from Kent's words in the fifth act of the play).

Working with Kermode gave Goehr the licence to focus on the aspects of Lear that most interested him, especially the journey Gloucester and Lear undertake. "Being politically radical, I have great scorn for who they are in the early part of the play. They are pompous fools, who are vain and mistaken in what they do. Frank and I were influenced by Foucault's idea of insanity when we were working on the text, the notion that through madness you obtain a kind of wisdom. The whole trajectory of Promised End leads to the scene between Lear and Gloucester, when one is mad and the other has no eyes. Through their misfortunes, they learn something about humanity, about modesty."

The end of Promised End shows how much Goehr and Kermode have rethought and rearranged Shakespeare's drama. The hanged Fool sings the final aria of the piece from the scaffold, using words from the third act. And – as in some recent theatrical productions – the same singer, Lina Markeby, plays both Cordelia and the Fool, since the characters are never on stage together in the original, and, as Goehr says, "Cordelia on her own is a poor part: a goody-goody, middle-class English girl, as George Orwell described her." They have also taken out much of the final act, Edmund's deathbed conversion to goodness, and his dilemma over which of the sisters – Goneril and Regan – to claim as his own.

Lear's death, at least, is the same. "The worst thing that happens to Lear is that he has to carry his dead daughter at the end of the piece, when it ought to be the other way round – though that wouldn't be very good with our cast [the waif-like Markeby would have a hard time carting Roderick Earle's imposing physique around the stage]. With his own death, Lear is transfigured. He becomes a sort of Blakeian figure. And I love one of his last lines: 'Undo this button.' Marvellous. I shall say that when it comes to my time. Schoenberg said 'Harmony,' and I shall say, 'Undo this button!'"

Frank Kermode died last month. "He was so angry about having to die before he could see the show. He wished he could have lasted long enough. Almost the last thing he said to me was: 'What shall we do next? Coriolanus?''' Goehr sees Promised End as the end of his own operatic output, which began in 1967 with Arden Must Die. "In all likelihood, this is the last time I'll write an opera – unless some chaps in suits come to me with an offer from the Royal Opera House, in which case I wouldn't say no." Goehr thinks of Arden Must Die as the only truly happy operatic experience of his career. The rest – Behold the Sun and the Noh-opera Kantan and Damask Drum – were "cock-ups", he says, thanks to the brainless butchery of directors or mediocre productions. But at rehearsals in Bethnal Green, in east London, he's ecstatic about the production of Promised End, with the company, English Touring Opera, director James Conway, conductor Ryan Wigglesworth, and his cast. "It's a dream team. These are ideal conditions for this piece."

Promised End, then, promises to be a fitting operatic swansong for Sandy. But there's one more thing. Goehr, like Lear, has three daughters. "When my middle daughter, Lydia, heard I was embarking on this venture she said, 'I hope I'm Cordelia, not one of the other two.' But in fact she's not the least like Cordelia. None of them are. They're all pains in the arse." For a second, I feel I've opened a can of worms of family relationships, the subtext that the opera must really be about. Then Goehr's lined, charismatic face opens into a laugh. "No they're not – they're all lovely!"

Promised End is at the Linbury Studio Theatre at the Royal Opera House, London, on 9, 11, 14 and 16 October (box office: 020-7304 4000), then tours until 26 November. Details: englishtouringopera.org.uk