With showmanship bordering on the supernatural, Bowie released his final album, Blackstar, on Friday, laden with pointers to his demise, then fulfilled the prophesy of his lyrics by passing away just two days later.

David Bowie has died at the age of 69

“His death was no different from his life – a work of art,” said his long-time producer Tony Visconti.

Diagnosed with cancer 18 months ago, a fact he had chosen to hide from the world, Bowie had plenty of time secretly to prepare for his own end, yet he had little control over the moment of its coming. Mr Visconti said Bowie “made Blackstar for us, his parting gift”, but even he was surprised by the uncanny timing of his friend’s passing.

Mr Visconti said: “I knew for a year this was the way it would be. I wasn’t, however, prepared for it.”

Brian May, the lead guitarist of the rock band Queen, with whom Bowie wrote and recorded the No.1 hit Under Pressure, said he had “no idea he was close to death” and “would like to have said something” to him.

Yet Bowie, intensely private when not performing, the ultimate showman when he was, had used his music to provide every possible clue that he was about the leave the stage.

The lyrics of Lazarus, one of the first tracks to be released, appear to be Bowie’s own requiem. It begins: “Look up here, I’m in Heaven! I’ve got scars that can’t be seen…” and ends with the words: “This way or no way/You know I’ll be free/Just like that bluebird/Now ain’t that just like me?/Oh I’ll be free.”

The video begins with Bowie lying in a hospital bed, and ends with him disappearing into a wardrobe. Other songs speak of graves and x-rays; videos for them have a recurring skull motif and the title track, Blackstar, has the lyric: “Something happened on the day he died, spirit rose a metre and stepped aside.”

The cover of the album, a black star on a white background, is the only one of Bowie’s 27 studio albums not to feature a picture of him.

Meanwhile Bowie’s wife of 24 years, the model Iman, 60, had posted messages on her social media pages which clearly referred to Bowie’s impending death, though his fans did not know it at the time.

On his birthday on Friday she posted a picture of her husband, quoting the comment he made at Madison Square Gardens on his 50th birthday: “I don’t know where I’m going from here but I promise it won’t be boring.”

The day before he died she tweeted: “Sometimes you will never know the true value of a moment until it becomes a memory.”

The previous day she wrote: “Life isn’t about avoiding the bruises. It’s about collecting the scars to prove we showed up for it,” and on December 19 she posted: “Everyone you meet is fighting a battle you know nothing about. Be kind always.”

Bowie’s health had been the subject of rumours for a decade or more, but none of them appeared to have been founded in any inside knowledge of what was really going on.

His refusal to perform at the London 2012 Olympics - where his song Heroes was played after almost every final - led to frenzied speculation about his health, though it appears to have been premature.

His biographer Wendy Leigh said that Bowie, who had once pursued sex, drugs and rock n' roll with equal energy, had suffered six heart attacks over the years, which he had also kept secret.

Bowie is understood to have died in New York, his adopted home city, with his wife, his 44-year-old son Duncan Jones and his 15-year-old daughter Alexandria by his side.

His death was announced by the family on Bowie’s official social media feeds, saying he “died peacefully surrounded by his family after a courageous 18 month battle with cancer”.

Many of those who were closest to him professionally were unaware of his illness. People who have worked for him for decades were told of his death overnight, shortly before the news was made public.

Brian Eno, his friend, producer and collaborator of 40 years, said: “David’s death came as a complete surprise, as did nearly everything else about him. I feel a huge gap now.”

He said that Bowie, who liked to use made-up names like Rhoda Borrocks when writing to his friends, last emailed him seven days ago.

“It was as funny as always, and as surreal, looping through word games and allusions and all the usual stuff we did. It ended with this sentence: ‘Thank you for our good times, Brian. They will never rot.’ And it was signed ‘Dawn’. I realise now he was saying goodbye.”

Ben Monder, a jazz artist who played guitar on Blackstar, said Bowie did not reveal his illness during recording sessions last year.

He told The Telegraph: "We didn't know anything. He seemed so full of life, he looked great. He was in really great spirits, laughing and joking; he must have been so brave."

The Belgian theatre director Ivo van Hove, who worked with Bowie on the stage musical Lazarus, which opened last month in New York, had been told by Bowie that he had liver cancer, by way of explaining why he would not be present at all the rehearsals.

He told The Times: "David told me, 'We have to work together very intensely for the next year and I want you to know, if I cannot be there, why that is.'

"It was a very intense time because he sometimes was very ill and in treatment but he came as much as possible to rehearsals, He was, at the end, very fragile - physically, not mentally."

Van Hove also described the show's opening night at the New York Theatre Workshop on December 7 during which he joined Bowie on stage to applause from the audience.

He said: "I was very aware that this would perhaps be the last time I would see him. He was really weak and when we came off stage he had to take a seat.

"I could see the tears behind his eyes, because he was not a man to show off his emotions. He was really in deep fear."

Mr Visconti said: "He always did what he wanted to do. And he wanted to do it his way and he wanted to do it the best way. He was an extraordinary man, full of love and life.”