Dozens of horrified onlookers watched as the man hung from the high-rise flat as police tried to persuade him not to throw himself off the window ledge.
It is believed that the 21-year-old man was supported by two men who also threatened officers not to enter the flat.
It is understood that a group barricaded themselves in the flat, in Muirhouse, after a party went badly wrong.
At around 5.15am, an argument broke out and a man was stabbed in the thigh.
The 19-year-old victim managed to stumble out of the flat and hobble to his home, in Muirhouse Gardens, leaving a large trail of blood behind him that later led police to the scene of the incident.
His condition worsened and he was rushed to the ERI, where he is reported to be in a serious but stable condition.
One insider said officers later entered the party flat and found large quantities of blood in a bedroom and the kitchen.
It is understood, however, that one reveller, who was believed to be under the influence of alcohol, panicked and threatened to jump out of the window if police attempted to arrest him.
Officers employed a negotiator as they tried to coax the man down from the ledge. Two others held on to him, and it is believed that they threatened to help him jump if police approached them.
One local resident, who asked not to be named, said they had been watching the stand-off since 7.30am.
He said: “There was a party that night and we heard it got out of hand. There was an argument and they said a guy was stabbed. He was losing lots of blood, so there was a trail of it through the building and on the pavement outside.
“The police followed the line of blood to the flat and it all kicked off. Two people have been dangling the lad from the window for hours.”
Another added: “His mates said they would help him if the police didn’t keep back. I think the party went a bit crazy.”
Negotiators finally managed to talk the man down from the ledge at around 11.30am. Two men were taken away by police, and the 21-year-old was taken to hospital suffering from hypothermia.
Police say a man has been arrested and charged in connection with a serious assault.
Meanwhile, a house party in Gorebridge turned nasty when a reveller was stabbed in the throat. The victim was taken to the ERI after he was injured at around 12.40am yesterday. A 37-year-old man has been arrested and charged.