The foam – which keeps the defenders’ wall 10 yards away and vanishes after 60 seconds – is expected to be used across the globe and is already being considered by Premier League bosses.

Thrilled Heine got to be at the opening match in Sao Paulo to see it in action at the highest level for the first time.

He said the spray being used at the competition was a “magical moment” and added: “I’d dedicated 14 years of my life to this idea.

"After the referee brought it out the first time I started receiving text messages from my family and friends.

“It was the first time I got emotional, my eyes welled up. I remember thinking, ‘I’m not crazy. It was all worth it’.”

Brazilian Heine, 43, grew up so poor he missed out on school so he could sell ice lollies on the streets to help his family.

One of five children, he lived in a cramped, three-roomed shack on a dirt road in Ituiutaba, a remote town in the south eastern state of Minas Gerais.

He said: “We all slept together in one small room. I never had any toys and we had few clothes. My parents sent me out to work at the age of eight.”

Heine dreamed of becoming a footballer but he struggled to make ends meet and instead had to work five menial jobs at once to avoid going bankrupt.

But one day – 14 years ago – he was visiting his parents’ home, where a match was playing in the background on an old television, and he had a eureka moment.

Fan: Heine Allemagne at one of the World Cup matches

He said: “I wasn’t interested in the game. I just happened to pass in front of the TV at the moment a free kick was being taken.

“I heard the commentator say, ‘will anyone ever find a way of keeping the wall in place?’ I stopped in my tracks and thought, ‘right, I’m going to find a way to do that right now’.”

Heine had never invented anything before but a week later he started working on the vanishing foam – a mixture of vegetable oils and gases butane and propane.

He said: “I thought about a temporary line, then I thought about foam because of its volume. I went into the ­bathroom and took a can of shaving foam.

“I closed my eyes and thought, ‘if I can spray a continuous straight line, I know I’m on to something’. I opened my eyes and there it was. From that moment on I didn’t stop working.”

Heine found a small local cosmetics factory which helped him come up with a formula, then he immediately filed for a patent for his new invention.

He said: “We had to find something which would not affect the players’ health, nor be damaging to the surface. So we based the foam on vegetable oil. But it had to disappear quickly, too.

“After experimenting a little, we managed to find the right combination of ­ingredients, making the foam stay visible for around a minute.”

Determined Heine then convinced the Brazilian Football Federation to try it out and it was used in the minor Belo Horizonte Cup in 2000. By 2012 the invention had been tested in 18,000 professional games.

Statistics showed the spray, called 9.15 Fair Play – the metric distance players have to be away from the ball – had reduced the average free kick time from 48 seconds to just 20.

Heine, who is in Rio de Janeiro for today’s World Cup final, now wants to see his creation become as vital a part of football as red cards and corner flags.

And the inventor is hoping to win big when the magic spray is finally approved worldwide, ­acknowledging he is likely to make a massive amount of money.

He said: “I hope that whatever financial gain is comparable to my 14 years of struggle. I’ve paid a high price. I chose not to see my children grow up so that I could make this work.”

He went on: “Most of all, though, I hope to have contributed to football – that we now have a tool that will help referees to keep order, help free kick takers score more goals, and improve the experience of football for everyone.”