"The only contract to be recognised by the board is the contract between McLaren Racing Limited and Mr Piastri dated 4 July 2022," governing body FIA said in a statement. "Mr Piastri is entitled to drive for McLaren Racing Limited for the 2023 and 2024 seasons."
Piastri won the F2 title last year.
"I'm extremely excited to be making my F1 debut with such a prestigious team as McLaren and I'm very grateful for the opportunity that's been offered to me," Piastri said. "The team has a long tradition of giving young talent a chance, and I'm looking forward to working hard alongside Lando (Norris) to push the team towards the front of the grid."
McLaren CEO Zak Brown called Piastri "one of the up-and-coming talents" and said he can succeed alongside the British driver Norris, who has six career podiums in F1.
"In Lando and Oscar we have a young, exciting F1 lineup with a huge amount of potential, standing us in good stead to achieve our future ambitions," Brown said. "Oscar is an exciting addition to the McLaren family, and we look forward to seeing him grow with our F1 team."
Alpine said it accepted the ruling, which leaves it with a vacant seat next year.
French driver Pierre Gasly, who drives for AlphaTauri, has been linked to the seat. So has Daniel Ricciardo, who is splitting with McLaren at the end of this year.
"We consider the matter closed on our side and will announce our full 2023 driver lineup in due course," Alpine said in a statement. "Our immediate focus is the Dutch Grand Prix and securing points in our fight for fourth in the constructors' championship."
Alonso is driving for Aston Martin next year as a replacement for four-time F1 champion Sebastian Vettel, who is retiring.