He was trying out a 45m (150ft) high zip wire at Victoria Park, where the Games are being shown on big screens.
The wire then lost momentum, leaving him suspended "like an odd Christmas decoration" above a crowd of people.
As onlookers snapped photos, he joked: "This is great fun but it needs to go faster."
Highwire act Boris defies political gravity
Lee Medcalf, who was at the event, said: "When Boris came down the zip wire, it was very James Bond-esque with him shouting 'Team GB'.
"However, he seemed to lose momentum and was left hanging there like an odd Christmas decoration for about five to 10 minutes.
"He spoke to the crowd, which had gathered beneath him, saying 'this is what it's all about; this is great, this is fantastic, this is Team GB'.
"I was thinking 'Yeah it's good, but you're still just hanging there'."
A spokesman for the mayor said: "The mayor has survived his first zip wire experience relatively unscathed.
"Clearly the judges are likely to have marked the mayor down for artistic impression, and unlike team GB, the mayor may not be winning too many Gold medals today.
"He does however remain unbowed."
Prime Minister David Cameron said London was "lucky to have" Boris Johnson as mayor.
Mr Cameron said: "If any other politician got stuck on a zip wire it would be disastrous.
"With Boris it's a triumph... London is lucky to have him."

They own the boundary wall along the River Arun at Arundel, West Sussex, which gave way in January after high tides and heavy rainfall.
But their insurers have refused to pay for repairs and the Environment Agency said it is the owners' responsibility.
Local MP Nick Herbert described it as a "deeply unsatisfactory situation".
Johnny Boylan, who is one of three affected homeowners, said the wall collapsed eight months after he and his partner moved into their house on River Road.
He said they repaired the top section of the wall when they moved in but had not realised at the time they owned the full wall down to the river bed.
"There is no mention of the river wall in our deeds," he said.
"It's an ancient part of the wall and now our insurance company is saying we are not insured because it was neglected."
Mr Boylan and his partner are currently unable to live in the property.
"It's a deeply unsatisfactory situation," Mr Herbert, MP for Arundel and South Downs, said.
"The Environment Agency and the public authorities are saying this is the householders' responsibility.
"That would be fine except that the insurers are saying this is the Environment Agency's responsibility."
He added the "poor policyholders" were now in a position where they may have to meet the bill "of several hundred thousand pounds".
The Environment Agency said its last inspection in September 2015 had not highlighted any "major issues" along the wall.
It said affected homeowners were "co-ordinating how repairs to this private flood defence will be taken forward, and we continue to advise them as appropriate".

At its peak more than 40 firefighters tackled the blaze in Albion Terrace, which started at about 08:10 BST.
The line, which was closed for safety reasons, was reopened at about 15:15.
South Yorkshire Fire and Rescue (SYFR) said crews were expected to be at the scene "damping down" throughout the evening.
It is believed the unit was being used to manufacture soft toys from the film Minions.
National Rail said trains are now running normally between Sheffield and Doncaster.
Kevin Ronan, from SYFR, said: "We're on top of the fire now. We're just in the process of damping down the remains of the incident.
"Parts of the building have collapsed already. It's been totally involved and it will probably have to be taken down."
He said the cause of the fire is under investigation.
The Mayor of London Boris Johnson was left dangling on a zip wire for several minutes when it stopped working at an Olympic live screen event.
[NEXT_CONCEPT]
Residents who had to evacuate their homes after a river wall collapsed are locked in a dispute over repairs they fear could cost £500,000.
[NEXT_CONCEPT]
A fire at an industrial unit in Hexthorpe caused disruption to train services between Sheffield and Doncaster for several hours.