Image copyright PA Image caption The documentary is a follow-up to 2013's David Bowie: Five Years

David Bowie learned his cancer was terminal only three months before he died, according to a BBC documentary.

David Bowie: The Last Five Years reveals that the singer found out his treatment was to be stopped as he made the Lazarus music video.

The documentary airs on BBC Two on Saturday - three days before the first anniversary of Bowie's death, aged 69.

It covers Bowie's A Reality Tour in 2003-4 as well as the last four years of his life.

Speaking in the documentary, Johan Renck, director of the Lazarus music video, said: "I found out later that the week we were shooting is when he found out that it is over... We'll end treatment or whatever capacity that means, that his illness has won."

Renck said that the video, which shows Bowie in a bed with his eyes bandaged and covered with buttons, was not about the singer's illness.

"To me it had to do with the biblical aspect of it, you know the man who would rise again, and it had nothing to do with him being ill.

"That was only because I liked the imagery of it."

Bowie's long-time producer Tony Visconti said in the documentary that the artist was "at the top of his game" when recording his final album Blackstar, released on 8 January 2016 to coincide with Bowie's 69th birthday.

Bowie died two days later.

Media playback is unsupported on your device Media caption Tony Visconti speaks about Bowie's swansong in a clip from David Bowie: The Last Five Years

Visconti added: "David had great, grand ideas. To become well known, famous, for him was initially to have the resources to realise what his ideas were.

"He really does come from that spirit, he just didn't want to be famous per se."

Directed by Francis Whately, the documentary is a follow-up to David Bowie: Five Years, which was broadcast in 2013.

David Bowie: The Last Five Years airs on Saturday 7 January at 9pm on BBC Two.

Follow us on Facebook, on Twitter @BBCNewsEnts, or on Instagram at bbcnewsents. If you have a story suggestion email entertainment.news@bbc.co.uk.