The 46-year-old Blink-182 drummer was pictured earlier this week being carried into Cedars-Sinai Medical Centre in Los Angeles on a stretcher.
Pancreatitis is an inflammation of the pancreas, a small organ located behind the stomach that helps with digestion.
Writing on Twitter, Barker said he had gone for an endoscopy "feeling great" but after dinner developed "excruciating pain" and had been receiving treatment in hospital ever since.
He said: "During the endoscopy, I had a very small polyp removed right in a very sensitive area, usually handled by specialists, which unfortunately damaged a critical pancreatic drainage tube.
"This resulted in severe life-threatening pancreatitis."
Barker, who is married to reality TV star Kourtney Kardashian, said he was "so very, very grateful that with intensive treatment I am currently much better".
Kardashian also shared a statement online, describing the last week as "scary and emotional".
"Our health is everything and sometimes we take for granted how quickly it can change," she wrote on Instagram.
"Travis and I went in for a routine endoscopy together and he ended up with severe, life-threatening pancreatitis.
"I am so grateful to God for healing my husband, for all of your prayers for him and for us, for the overwhelming outpouring of love and support.
"I am so touched and appreciative."
Kardashian, who recently changed her surname on her official Instagram page to Barker-Kardashian, thanked the specialists, doctors and nurses at Cedars-Sinai for taking care of her husband and her during their stay.
She added: "It's crazy how sometimes words could never truly express the gratitude or feelings I have inside of me."
News that Barker had been admitted to hospital earlier this week prompted messages of support from the worlds of music and celebrity.
On Thursday, his daughter Alabama, 16, thanked friends and fans for their "prayers and love".
Barker has two children with his ex-wife and model Shanna Moakler, a former Miss USA - 18-year-old Landon and Alabama.