He was in his hotel room in London, where he is due to perform at the Lyric Theatre, when officers barged in.
Tweeting about his predicament he said hotel staff mistook him for a guest who had threatened staff with a knife.
He was handcuffed and led from the room shouting "but I'm in my kegs". Met Police said he was mistakenly detained.
Geordie comic Ramsey is touring the country with his show All Growed Up and provided a running commentary on Twitter of Sunday night's events.
"Well... The police have definitely just kicked my hotel door in and handcuffed me," the first tweet, sent at 00:47, said.
In a string of follow-up tweets he said: "Hotel staff ID'd me as someone who had been in the hotel earlier threatening staff with a knife. So when I checked in just now they called the police and sent them up to my room! I kept asking 'is this a joke?' When he said 'no come with us' police put the handcuffs on me and began to march me out of the room when I shouted 'but I'm in my kegs'.
"I love the idea that someone who was in earlier threatening staff with a knife, would then check in later for a kip!!", he tweeted.
On his way to breakfast he said he was taking precautions by wearing an anonymous black cap and black T-shirt, lest he be mistaken for "a murderer or something".
Ramsey - who is a panel show regular and has also starred in BBC sitcom Hebburn - tweeted that his ordeal might be discussed during his stand-up routine later.
A Met Police spokesman confirmed officers had initially been called to deal with a man who was threatening hotel staff with a knife in a racially aggravated attack.
Officers returned to the hotel after midnight when they mistakenly arrested and subsequently released Ramsey, the spokesman said.

The grey and white mammal became stuck on sandbanks on Thursday at Saltney Ferry, near Chester.
An RNLI lifeboat hoisted the dolphin out of the water before carrying it out to sea, according to the British Divers Marine Life Rescue.
The dolphin, in the river since Monday, will be taken three miles off the coast of Rhyl.
Alan Forrester, lifeboat operations manager with Flint RNLI, told Radio Wales the rescue boat was launched at Connah's Quay after the dolphin was seen "floundering" on a sandbank.
It was hoisted onto the lifeboat and carried down the river towards open water.
An animal welfare officer is also onboard.
"We've got what we call an ambulance pouch, which is a rolled up stretcher," Mr Forrester added.
"They laid that on the sandbank and rolled the dolphin into the stretcher and lifted it into the lifeboat.
"It's rather a large dolphin. It's lying there nicely, they've got buckets of water to keep it cool - everything seems to be ok at the moment."
The mammal was originally spotted by the public on Monday in Connah's Quay docks and became stranded briefly on Tuesday after turning to make its way to Flint and towards the sea.
Liverpool coastguard wanted to hold off a rescue attempt for as long as possible to avoid coming into physical contact with the mammal in case it is rejected back at sea.
A coastguard team was earlier deployed to the area to try to ensure the safety of spectators trying to catch a glimpse of the dolphin.
It is thought the dolphin swam up the river during the high spring tide.
It is rare for dolphins to be seen in the River Dee but a pair of porpoises were reported near  Queensferry Bridge eight years ago.
Comedian Chris Ramsey was arrested at midnight in his underpants - but has since said he sees the funny side of the case of mistaken identity.
[NEXT_CONCEPT]
A dolphin has been rescued after swimming miles up the River Dee in Flintshire four days ago.