Ecuador should come to London more often. What should have been a useful but not hugely significant World Cup warm-up for the South Americans and Australia, turned into one of the most absorbing games of the season.

Trailing by three goals at half-time after an absolutely shambolic start, somehow it turned the match on its head and they completed a miraculous 4-3 comeback in the dying seconds. An unlikely battle of Bermondsey that will live long in the memory.

If the yellow swathes of Ecuadorians in the Dockers stands was not strange enough, the game lurched from one bizarre turn to the next throughout an enthralling 90 minutes.

It finished with Edison Méndez firing the ball past Brad Jones, Australia’s third goalkeeper of the evening, in injury time following excellent work from Antonio Valencia on the right wing. Before that the two sides had shared six goals, Australia’s coming in the first half, before their goalkeeper Mitch Langerak was sent off in the 58th minute.

Tim Cahill, returning to Millwall after leaving the club for Everton 10 years ago, found the net first and in doing so became Australia’s leading all-time scorer, ahead of Damian Mori. His 30th international goal was a header from a corner early on, before stooping to add a second, also with his head, just after the half hour.

Between his two efforts Cahill also played a key role in Australia’s second, fouled in the Ecuador penalty area following a clumsy challenge from Gabriel Achilier. The Australia captain, Crystal Palace’s midfielder Mile Jedinak, stroked home the penalty.

Cahill said: “It’s a dream come true, to break this record is something that I want to go on and do more. It was a really proud moment for me. It’s funny that I could have one of the best moments of my career where it all started [at Millwall]. It’s exciting times for Australian football at the moment and the way we played tonight showed we have a great style and intent.

“The first half was some of the greatest football I’ve ever seen from the Socceroos and I’ve been around for a long time,” Cahill said.

“The youngsters really impressed me. [But] when we had the man sent off, that’s when the damage was done. If it’s 11 versus 11, we are not losing that game.”

That said, Australia capitulated woefully in the second half, with Ecuador’s myriad changes at half-time paying off. Curtis Good and Swindon’s Massimo Luongo both made their debuts but the second-half was an aberration.

Ecuador pulled one back through Fidel Martínez in the 57th minute, before Langerak spectacularly mistimed a challenge on Enner Valencia seconds later to concede a penalty. Segundo Castillo scored and the equaliser came 10 minutes later, Valencia squaring for Enner Valencia whose scuffed effort in the six-yard box crept in.

Ecuador’s support, which significantly outnumbered Australia’s, were jubilant, and an unlikely comeback was completed in injury time through Méndez.

Australia’s coach, Ange Postecoglou, said: “It’s extremely disappointing. In the second half we lost control of the game a fair bit. I’m supremely confident we’ll be better for it. I have huge belief in the direction we are going. There are going to be some bumps along the way. You never like to lose because the players put a massive shift in.

“I was really happy with our shape in that first half and the way the team were able to play the kind of football we wanted to.

“We were really bright and positive and every time we got the ball we tried to find little angles for ourselves. It was exciting to see ... it was definitely a step forward.”