In 2008, we had such a candidate run and lose.
If he had won, the case would not have gone to court. It would have come down to that boring joint session of Congress on 6 January 2009 at 1300 EST, Dick Cheney in charge, when they officially counted the electoral votes. If the foreign-born McCain had had more electoral votes, he would have been President, removable only by the impeachment process.
In the event, the natural born Kenyan-commie-in-his-own-mind turned out of have the most votes, so he was President, removable only by the impeachment process.
It's possible for congress critters to object to a state's electoral votes. In that case, the House and Senate have two hours to consider the objection. If both houses agree, the electoral votes are rejected.
If, after all objections, no candidate has a majority of the electoral votes, it is up to the House, voting state by state, to pick the President.
Notice that the Supreme Court, nor any courts, have any role in the process.
If Cruz were to run and win the majority of the electoral votes, he would be President, constitutional law quacks notwithstanding!
The Panama Canal Zone (Spanish: Zona del Canal de Panamá) was an unorganized territory of the United States from 1903 to 1979, centered on the Panama Canal in the Republic of Panama.