The NBA is partnering with Rio de Janeiro's sport secretary of state to develop basketball in the largest favela in Rio.

The greatest basketball challenge in Rio de Janeiro's largest favela is actually getting onto a court.

Within the cascading hillside shanty city of Rocinha—home to an estimated 100,000 people—which overlooks the wealthy beach neighborhood of São Conrado, there are only three ill-equipped quads and just one multi-sports complex for a population that has increasingly become fascinated with basketball.

"Most of [the courts] aren't covered so when it rains, the court gets wet and we can't play," said Leandro Lima, 33, an amateur player who lives in Rocinha. "There's no maintenance or support. And they're always poly-sports areas so we have to share with other sports and people from other neighborhoods. We're always hoping for things to improve."

But as of next year, Rocinha will become the latest location and the first in Brazil to host a Jr. NBA program, the grassroots youth league run by the NBA for children aged 6-14.

The program, which has been rolled out to more than 30 countries, allows any organization or league to register as members, receiving NBA support to teach youngsters "the fundamentals of the sport while instilling core values including teamwork, respect and sportsmanship".

Final arrangements were being agreed in Rocinha this month, where Jr. NBA is due to open a center early next year. They plan to begin coaching pupils by the start of the academic year in February. It will be the first time an NBA Jr. program will run in South America.

Under the program, a partnership between the NBA and the sports secretary for the state of Rio de Janeiro, the favela's multi-sports complex will be renovated to offer better facilities and coaching for Rio's keen young ballers..

"Jr. NBA has already had success in various parts of the world for years," said Samy Vaisman, spokesman for the initiative, which is also present in South Africa, India, Italy, the UK and Mexico among others. "Soon, it will arrive in Uganda and Lithuania. In Brazil, the league is training coaches, implementing the methodology already used around the world as well as providing all the necessary material."

Basketball's popularity has grown in Brazil, where a Deloitte study found it among the top sports expected to grow in the coming years. As a result, the country has emerged as a priority market for the NBA, which has been organizing events in Brazil since 2002.

Last year, the NBA signed a deal with the top Brazilian league to manage its marketing and advertising deals to promote the sport and tap into the lucrative potential of a population of more than 200 million. The National Basketball League (LNB) was formed in 2008 for the country's best teams and has followed the NBA All-Star format in its successful "Jogo das Estrelas" competition.

"By partnering with the NBA, we will be able to collaborate on programs and procedures that will foster growth in Brazil and deliver an exciting product to our dedicated fanbase," said Cássio Roque, president of the LNB.

The federal government has also granted extra investment ahead of the Rio 2016 Olympics that will also establish a talent pool for the national team, which won gold in this year's Pan-American Games, beating second-place U.S. and winning 86-71 against Canada in the final. (So far, Brazil, Australia and the U.S. have qualified for Rio 2016's men's competition, with Brazil, Australia, Canada, the USA and Serbia having booked their place for next year's women's competition.)

The R$5.4 million (U.S. $1.4 million) funding as part of a partnership with the LNB provided 20 kits ,including collapsible floating floors, scoreboards and baskets for sports clubs around the country.

The history of basketball in Brazil is closely entwined with its origins in North America—it was one of the first countries to play the sport.

American Augusto Shaw, after graduating with an arts degree from Yale, and with an invitation to teach at Mackenzie College in São Paulo, arrived in Brazil in 1894 with a basketball in his luggage, according to the Brazilian Basketball Confederation.

The game first took off with women. Basketball was slower to develop among Brazilian men because Charles Miller brought soccer to Brazil around the same time.

Even today, some of the top basketball teams in Brazil are affiliated with soccer clubs, such as Flamengo, which is part of the Clube de Regatas do Flamengo, one of the biggest soccer teams in Brazil. The team played the Orlando Magic in a pre-season match in October.

The Brazilian Basketball Confederation was founded in 1933 and Brazil won its first team medal for basketball in 1948, winning bronze again in Rome in 1960.

In 1994, the women's team won the world title and was crowned runners up at the 1996 Games in Atlanta.

"Believing in the potential in Brazil, understanding the passion of Brazilian fans and within an expansion plan developed by the NBA, an office was inaugurated in Rio in 2012," Vaisman added. "Since opening, the NBA's activities in Brazil intensified a lot in various ways."

Several exhibition showcases including 10 NBA3X events have taken place in Brazil in the last three years, while the first NBA league game took place in Rio in 2013 as part of the build-up to the Olympics.

The regular season matchup in 2013 between the Bulls and the Wizards took place inside the Olympic Park complex in Barra da Tijuca, where basketball games will take place during the 2016 games.

"For many years, there were plans for the NBA to come to the country and establish itself," Arnon de Mello Neto, executive director of NBA Brazil, told reporters in 2013. "It's an old dream that is coming true now. Brazil is going through a very good international moment, basketball is growing again and there would be no better time for the NBA to enter the country. It is an achievement, not just for the NBA, but for Brazilian fans."

Vaisman also pointed out there was a record nine Brazilians playing in the NBA this season including Anderson Varejao with the Cleveland Cavaliers, Nene of the Washington Wizards and Marcelo Huertas with the Lakers.

Anderson Varejao was one of nine Brazilians on an NBA roster this season. Photo by Mark L. Baer-USA TODAY Sports

Rocinha, meanwhile, has already proved a breeding ground for basketball talent. One player, also named Leandro Lima, said he turned to the game to escape the violence that has long blighted the favela, where drug gangs battle between each other for territory, residents regularly report shoot-outs and police fail to win respect or keep order.

Within the favela itself are separate and distinct neighborhoods which are caught in a turf war, from the edges of the affluent São Conrado district on the flat beachside to the stacked hidden corners of the mountainous vista where gang law still rules. The densely populated hillside is riven with tiny alleys between cinderblock houses, making it difficult to police.

Lima lost his father at age 3, and was raised by his mother, a story not uncommon in Rocinha. Eventually, he left Rio for Spain, and became the only Brazilian to compete in the Red Bull King of the Rock street basketball championship held at Alcatraz prison in San Francisco in 2012/13.

Lima, who started his own youth project in Rocinha some years ago but was unable to maintain it for a lack of funding and support, said he hoped to come back one day and start his own academy in Rocinha. "I will show kids what basketball did for my life, and I'm sure that many of them will go further than I managed, it helped me a lot in my life and the least I can do is give back," he told VICE Sports.

Asked about plans for the Jr. NBA school, Lima added: "It's great. Rocinha deserves a program like this, and without a doubt, it will train up many new talents in Brazilian basketball, and who knows, maybe in the world."

These days, the favela has been "pacified" or occupied by dedicated police units (UPPs) to improve security, with parallel UPP social projects, including sports programmes such as new soccer pitches. But tension remains between the residents and authorities, particularly since the disappearance of a bricklayer named Amarildo de Souza, who was allegedly tortured and killed by pacification police in July 2013.

Rocinha is Rio de Janeiro's largest favela. Photo by ANTONIO LACERDA/EPA

Authorities hope that the Jr. NBA program will benefit not only the 100 schoolchildren who will get coaching next year, but also the whole community thanks to the improved sports centre.

Marco Antônio Cabral, secretary for sport, leisure and youth, said: "Our young people, who already frequent the complex, will get to practise sport of a yet higher quality."

The refurbished sports complex is expected to start accepting young people from the start of the next academic year.

"It's a platform that aims to popularize and develop the sport, offering young people from eight to 15 the opportunity to practice sport and have an active life, based on concepts such as teamwork, leadership and respect," Vaisman said. "The partnership with the secretary aims to offer basketball in school hours as an option for young people and children."

The Cavs' Anderson Varejão added: "I'm happy to see Jr. NBA arriving in Brazil. It's good to know that our young people will have the opportunity to get involved in basketball and have a healthy life."

But those in Rocinha worry the elite academy, where 100 children will be drawn from those who register, may exclude the vast majority of enthusiastic young basketballers in the community, already competing for court time. But the social benefits of bringing a basketball project to a community as complicated and delicate as Rocinha are also crucial.

"I hope it's going to bring some recognition, and benefits beyond the sport," said Lima, who also edits the website faveladarocinha.com. "Basketball is about more than just putting the ball in the hoop."