MILAN — Former Knicks forward forward Danilo Gallinari rejoined his former Italian team Olimpia Milano on Tuesday, agreeing to play until the NBA lockout ends.

“I’m happy for the opportunity that Olimpia offered me to get back on the court with the team that I had some unforgettable experiences with,” Gallinari said. “I hope to give the Milan fans more to cheer about and give them back in return the affection they showed by following me once I reached the NBA.”

Olimpia’s new coach is Sergio Scariolo, who guided Spain to the European Championship title Sunday in Lithuania. Along with fellow NBA players Andrea Bargnani and Marco Belinelli, Gallinari was on the Italy squad that failed to advance to the second round.

“The only player for which we would have even considered making an exception to the rule of not hiring ’part-time’ players was Danilo Gallinari,” Scarolo said. “We’re confident to get from him, even for only a brief time, the effort and dedication needed to become part of the team.”

Gallinari played for Olimpia from 2005 to 2008 before being drafted sixth overall by the Knicks in 2008. In February, the Knicks traded him to the Nuggets in a three-way blockbuster deal for Carmelo Anthony.

Gallinari’s father, Vittorio, also played with Olimpia.

Also known by its sponsor’s name Emporio Armani, Olimpia has a difficult series of games to open this season’s Europa League, where it will face Maccabi Electra Tel Aviv, Real Madrid and Anadolu Efes Istanbul.

“With the time frame coinciding with our goal of qualifying for the top 16 in the Europa League, that obviously gave us extra motivation to make this deal,” Scarolo said.

Olimpia opens the Italian league season against Varese on Oct. 9.

Gallinari is expected to travel with Olimpia to a preseason camp in Spain on Thursday.

Other NBA players have committed to leagues outside the United States.

Nuggets free agents Wilson Chandler and J.R. Smith plan to play in China, Denver’s Ty Lawson will play in Lithuania and New Jersey Nets All-Star Deron Williams signed with the Turkish club Besiktas.

The NBA season usually begins in late October but owners and players have so far failed to agree on a new labor deal. The sides are at odds over how to divide the league’s revenue, a salary-cap structure and the length of guaranteed contracts.