The Scottish writer posted a message on his official website saying his next novel The Quarry, due to be published later this year, would be his last.
The 59-year-old's novels include The Wasp Factory, The Crow Road, Complicity and the Culture series.
The statement said his health problems came to light when he saw his doctor, suffering from a sore back.
He was diagnosed with jaundice, before further tests established the full extent of his illness.
In the personal statement on his website, Banks said he had asked his partner Adele to marry him and was now on a short honeymoon.
Banks' first novel The Wasp Factory was published in 1984 and introduced the Fife-born writer as  a dark new force in British literature.
Described in turn as "macabre... bizarre... and depraved," the book was included in a 1997 poll of the 20th Century's top 100 books, placed higher than Charlie and the Chocolate Factory and Steinbeck's Of Mice and Men.
Subsequent novels, including Espedair Street and The Crow Road, were adapted for radio and television and his 1993 book Complicity was made into a film in 2000, starring Trainspotting's Jonny Lee Miller.
Considered one of Scotland's foremost writers, most of whose books are set in his home country, the writer ventures further afield in his parallel career as a writer of science fiction under the guise of Iain M Banks.
Using his middle name of Menzies - on the advice of his publisher who said it looked "more American" for a US market - several of Banks' sci-fi works are set in the Culture universe, a semi-anarchist utopia.
His most recent work in the so-called Culture series - The Hydrogen Sonata - was released last year. In its review - the Independent praised Banks' "taste for the absurd".
Fellow Scottish author, Ian Rankin, said the news of Banks' terminal cancer was "just awful".
He Tweeted: "Typical of Iain to propose marriage to his partner Adele with the words 'Will you do me the honour of becoming my widow?"
Banks, who lives in North Queensferry, Fife, said he had cancelled all future public engagements.
He said: "The bottom line now, I'm afraid, is that as a late-stage gall bladder cancer patient, I'm expected to live for 'several months' and it's extremely unlikely I'll live beyond a year.
"So it looks like my latest novel, The Quarry, will be my last."
He said the disease had spread to both lobes of his liver, and possibly his pancreas and lymph nodes.
The author said there was little chance of surgeons being able to remove the tumours because of how far they had spread.
He has asked his publishers to bring forward the publication of his new book to "give me a better chance of being around when it hits the shelves."
Banks also praised NHS staff who have looked after him - and said he may undergo chemotherapy to extend his life when his jaundice clears up.
He said: "We're all just sorry the outcome hasn't been more cheerful."
Born in Fife, Banks studied at Stirling University before publishing his first novel, The Wasp Factory, in 1984.
NHS Gallbladder cancer
Macmillan - Gallbladder cancer
He has alternated between mainstream and science fiction novels, which he wrote under the name Iain M Banks.
In 2008, he was named one of the 50 greatest British writers since 1945 in a list compiled by The Times.
News of his illness was described as "terribly sad" by First Minister Alex Salmond.
He said: "Iain Banks is a remarkable writer who has made a lasting contribution to Scottish literature and culture, inspiring and enthralling readers for 30 years.
"My thoughts are very much with Iain, his wife and family and his friends at this very difficult time."
A website has been created for friends and fans to leave messages for Banks.
Taggart actor Colin McCredie is among the people who have expressed their shock on Twitter.
He wrote: "Sad news about Iain Banks and his illness. There was a period of about 5 years when his output was phenomenal!! Always loved Espedair Street."
Edinburgh Book Festival tweeted: "Such sad news. Iain Banks our thoughts are with you and your loved ones."
The Scottish Book Trust added: "We're all shocked and saddened by Iain Banks' news. We send our best wishes to him, his family and friends."
Among the fans who commented on the news was @flashboy, who tweeted: "Horrible news about Iain Banks. Two of our best authors."
Author Iain Banks has revealed that he has late stage cancer and is unlikely to live for more than a year.