Andrejs Borodins, 53, of the container ship Frifjord, was caught after a pilot at Dundee harbour came on board to help him navigate the 250ft boat under the Tay road and rail bridges in the city.
The pilot, Barry Nisbet, found Borodins drunkenly staggering and incoherent and completely unable to steer the ship under his direction. Mr Nisbet called harbour officials who notified police.
The ship's first mate had to come to the wheel to steer her while Borodins retired to his bunk to sleep off his intoxication.
The Latvian national appeared yesterday at Dundee Sheriff Court and pleaded guilty on indictment to a charge under the Railways And Transport Safety Act 2003.
Fiscal depute Eilidh Robertson told the court Borodins and his three crew had intended to sail the vessel - used to transport animal feed and registered in the Bahamas - from Perth to Norway on Monday of last week when the incident happened.
She said: "The vessel made its way from Perth and at around 7.40pm, in the area of Balmerino, Barry Nisbet, a pilot from Dundee harbour, came aboard.
"He was to guide the vessel through the shipping lanes at the Tay bridges.
"He introduced himself to the accused and became concerned about his demeanour.
"Mr Nisbet gave the accused instructions in how to get the vessel through the shipping lanes and noted he was unable to carry out instructions and was unsteady on his feet.
"He formed the impression the accused was under the influence of something and contacted Dundee Port Authority, who notified police.
"Officers attended at 8.40pm at Dundee harbour after the ship had docked and found the accused asleep in his bunk.
"The accused failed a breath test and was removed from the vessel and taken to police HQ.
"He later told police when charged that he 'arrived at the port sober and had a drink in the port'."
Defence solicitor John Kydd said Borodins' employers were standing by him, but he would "have to face his wife and explain himself" when he returned to Latvia.
He said: "He blames no-one else but himself for this. He says alcohol is not readily available on the ship and is not allowed on board.
"He has been at sea for 25 years and was promoted to captain in 2013. He is thoroughly ashamed of his conduct. He tells me he has got a lot of explaining to do when he gets home to his wife as to where he has been.
"He is a hard-working man who has let himself, his company and his family down."
Sheriff Alastair Brown remanded Borodins, an inmate at Perth Prison, in custody and deferred sentencing until later this month. The sheriff called for background reports to help him decide what he will do with the captain.
The sheriff told Borodins: "The possibility of you running aground, of colliding with one of the two bridges, endangering the lives of your crew, or having an accident in which the waterway was blocked, must have been very high.
"The risk of environmental damage to the Tay, which is important to the economy and ecology of Scotland, must have been high.
"You had to be relieved of your command because you were a menace.
"This is an offence that has much in common with a serious breach of health and safety law or with culpable and reckless conduct.
"It is not analagous with driving with excess alcohol - it is very much more serious than that.
"You had a breath alcohol level within touching distance of four times the limit.
"This is a very serious offence and a sentence of imprisonment is a real possibility - indeed it is a probability."
The ship set sail on Tuesday of last week bound for Norway without Borodins.