Winning a World Cup is a steep enough challenge.

Pelé had the gifts, and talented and remarkable team-mates, to accomplish that not once, not twice, but three times.

Trying to win over a country? That might be even harder.

That seemed to be an impossible mountain to climb, even for a man nicknamed O Rei (The King). Yet, in 1975 Pelé took a gamble and ventured to the one major nation on earth that had not embraced the beautiful game.

“I was retired from my team, Santos, I was retired from Brazil from the national team,” Pelé told me a few years ago when he questioned why he would want to come to the United States in 1975. “What I am going to do in New York? I come from the two biggest teams, the biggest moments. Clive Toye [New York Cosmos president] told me, ‘Listen, we want to make soccer, football, as big as it is in Europe and South America.’

“When I signed with the Cosmos, the Cosmos were almost a university team. Later on, we became the best team, almost in the world. After we got some excellent players, then the Cosmos became No 1.”

Sunday is the 40th anniversary of Pelé’s retirement game, a lavish affair in which a capacity crowd of 75,646 jammed New York’s Giants Stadium to say farewell and thank you to the man many regard as the world’s greatest player. The celebrity list included Robert Redford, Barbra Streisand, Diane Keaton, Mick Jagger, Muhammad Ali and Henry Kissinger. It was a fitting finale for a king.

During his three-year tenure in the States, Pelé helped ignite a soccer boom the USA is still feeling today. While the original incarnation of the North American Soccer League went bust after the 1984 season, soccer, slowly, but surely, began to take root. It is now an established part of the country’s sporting ecosystem – some of the teams in the league attract crowds of upwards of 40,000, and as a participant sport, particularly in schools, it has risen dramatically over the last 10 years.

Back then, it struggled. It was considered a sport popular among immigrants and even ridiculed as a “commie” sport by its biggest detractors as it fought for acceptance in the media.

But when Pelé signed with the Cosmos, however, he was difficult to ignore. Whenever the Cosmos came to town, he became the major sports story as US stadiums played to full capacity to watch Pelé perform some magic. His first game was broadcast to over 20 countries and 300 journalists from all over the world were in attendance.

Pelé at Giants Stadium in 1977. Photograph: Focus On Sport/Getty Images

Pelé, who would sign autographs all day for fans until team officials pulled him away, also opened the door for many other stars to play in North America. Giorgio Chinaglia followed him to the Cosmos, then Franz Beckenbauer and Carlos Alberto before several other world-class players helped fill out a formidable Starting XI. Over the next few years other legends decided it was fair game to test the NASL waters, including Johan Cruyff, Bobby Moore, George Best and Gordon Banks, among others.

They helped lay the groundwork for what we have today.

Looking back 40 years, it would be easy to say those were the good ole days. Pelé and the Cosmos brought glamour and glitz – and huge crowds. But, in some respects, New York City in the mid-70s was a mess. It tried to move forward while other forces pulled it back, enduring some tumultuous times while fighting financial difficulties and a notorious crime rate.

When New York City asked for a financial bailout from the federal government and President Ford in 1975, it was rejected, leading to this memorable New York Daily News headline: Ford to city: drop dead.

During the summer of 1977, Son of Sam terrorized the city with random killings until he was apprehended that August.

Times Square was far from the more welcoming place it is today as XXX-rated entertainment and filth dominated the streets. In 1977 the city went dark during a midsummer blackout during which looters gave it a black eye for lawlessness.

Even the Cosmos experienced their share of turmoil. After a shaky start, they fired popular coach Gordon Bradley and replaced him with Tampa Bay Rowdies coach Eddie Firmani in June. Toye was forced out as team president.

On the field, the team added two former World Cup champions – West Germany’s Beckenbauer and Brazil’s Carlos Alberto.

In June, the Cosmos attracted an NASL-record 62,394 fans to Giants Stadium for a 3-0 victory past the Rowdies as a 37-year-old Pelé reigned with a hat-trick.

The team suddenly caught lightning in a bottle as attending Cosmos games became the trendy thing to do. Even gritty Daily News columnist Dick Young, a baseball aficionado, admitted he was won over. “I had been seduced by Pelé,” he wrote.

By the end of the season, Pelé did not always have to be the leader of the band thanks to his superlative supporting cast. In the first leg of the quarter-final series, they attracted a US-record crowd of 77,891 for what turned into an 8-3 rout of the Fort Lauderdale Strikers at Giants Stadium. In the second leg of the semi-finals against the Rochester Lancers, a 4-1 triumph, the Cosmos attracted 73,669 for a midweek game in the rain as Pelé tallied his final competitive goal.

The win propelled the Cosmos into the Soccer Bowl against the Seattle Sounders in Portland. Their goals were pretty obvious: to win the championship for the king.

Pelé did not figure much in his last competitive match as Steve Hunt and Chinaglia provided the heroics as the Cosmos won 2-1.

What transpired afterwards has been seared into my mind. I could not believe what I saw or heard from the loudest and crowded locker room. The entourage of Brazilian media lifted their countryman onto their shoulders and paraded him around while chanting “Pelé! Pelé! Pelé!”

Later, Pelé sat at his locker in front of a media scrum as he seemed at peace with himself and the world. “God has been kind to me,” he said. “I can die now.”

Of course, he didn’t.

Pelé in his Cosmos No 10 shirt. ‘Love is more important than what we can take in life.’ Photograph: Bettmann Archive

After a tour of Asia, the Cosmos returned home for one final goodbye to the king in a surreal farewell game at a packed Giants Stadium.

During pre-game ceremonies, the captains of the five last World Cup championship teams were introduced – Brazil’s Bellini (1958), Mauro (1962) and Carlos Alberto (1970), England’s Moore (1966) and West Germany’s Beckenbauer (1974).

Jeff Carter, the son of then President Carter, read and presented Pelé with a plaque: “Presented to Pelé for the smiles he put on children’s faces, the thrills he gave to fans of this nation and the dimension he added to American sports. Pelé has elevated the game of soccer to heights never before attained in America and only Pelé, with his status, incomparable talent and beloved compassion could have accomplished such a mission. The United States of America is deeply grateful.”

– President Carter, 1 October 1977

Eventually, an emotional Pelé stepped to the microphone. “Ladies and gentlemen, I am very happy to be there with you in this greatest moment of my life,” he said. “I want to thank you all every single one of you. I want to take this opportunity to ask you to pay attention to the young of the world, the children, the kids. We need them too much. And I want to ask you because I think that, I believe that love is the, the …”

Tears streamed down his cheeks.

“Love is more important than what we can take in life,” he said. “Everything passes. Please say with me, three times – love! Love! Love!”

The stadium scoreboard repeated those words – “Love! Love! Love!” as the crowd responded in unison.

Overcome by emotion, Pelé tried to speak before managing: “Thank you very much.”

Roberta Flack sang The Star Spangled Banner before Sérgio Mendes and his band played the Brazilian national anthem.

There was still a game to be played in the rain. Quite fittingly, it was between the only two clubs for which Pelé wore a jersey – the Cosmos and Santos.

The Brazilian side grabbed a 14th-minute lead on Reynaldo’s goal.

While performing for the Cosmos in the opening half, Pelé gave the crowd one last glimpse of his greatness with 2.34 remaining. He drilled a free-kick past Santos goalkeeper Erani, who dove to his left in vain to stop as it nestled into the back of the net. The crowd went crazy on Pelé’s 1,281st goal of a 22-year career and 64th in 106 matches with the NASL side.

More ceremonies at halftime. While standing in the center circle, Pelé took off his No 10 Cosmos shirt and gave it to his father, Edinho. He then put on the No 10 of Santos.

While many fans hoped for a Pelé goal for Santos, he could not duplicate his scoring feat as his replacement, Ramon Mifflin, connected to give the Cosmos a 2-1 win.

Fans at Pelé’s final game. Photograph: Colorsport/Rex/Shutterstock

After the final whistle, Pelé walked back to the center of the pitch, took off his Santos jersey and presented it to his first coach. With the rain pelting the field, a shirtless Pelé took one last victory lap around field with the crowd chanting “Pelé! Pelé! Pelé!” He was lifted on to the shoulders of several Santos and Cosmos players, including goalkeepers Shep Messing and Errol Yasin. He exited the field with an American flag in one hand, a Brazilian in the other.

“I die a little bit today,” Pelé said afterwards. “Now I am born again to another life. You see, I stop playing soccer because I want to stop, and that is important.”

It might have been the end of an era for American soccer, but it was the beginning of something much bigger for the sport, though it would take years for those seeds that Pelé and friends planted to grow.

“It was the best thing I did in my life,” he told me a few years ago about playing in the US. “I thank God for that because I became more well-known throughout the world after I came here.”

Forty years on, no statues have been built for the man who helped to transform American soccer.

But perhaps there are greater monuments that honor Pelé.

After all, we seemingly can’t drive anywhere in the US without seeing a soccer park or field.

There is a professional league – Major League Soccer – that will complete its 22nd season with many of the clubs sporting soccer-specific stadiums.

The women’s national team has set international standards that will be difficult to duplicate.

Soccer haters have died off and the sport, perhaps most crucially, has taken root among schoolchildren and their parents. It has put down roots in communities across the states and this time it is growing from the bottom up. With American football enduring a difficult time with worries over brain injuries for children and adults, “soccer” has seen its popularity grow as an alternative to the other “football”.

Now, that is a legacy certainly fit for a king.