Proposals to build the 11-turbine European Offshore Wind Deployment Centre (EOWDC) off the coast of Aberdeen were approved by the Scottish Government in March last year.
The scheme is bitterly opposed by the American tycoon, who claims it would spoil the view from his luxury golf course.
Trump International Golf Club Scotland and the Trump Organisation went to the Court of Session in Edinburgh for a judicial review of the Scottish Government's decision not to hold a public inquiry on the windfarm application and of their decision to grant consent for the project.
But after a hearing lasting several days in November, judge Lord Doherty today dismissed their petition.
Mr Trump subsequently said he would appeal against the ruling, as he revealed he has bought his first links golf course in Ireland - Doonbeg Golf Club in County Clare.
In a brief statement, he said: "We will appeal this decision and in the meantime we will be focusing all of our investment and energy towards our new acquisition on the Atlantic Ocean in Ireland."
In an earlier statement, The Trump Organisation said the Aberdeenshire turbine development is doomed, despite the court ruling.
"Today's decision has not altered our unwavering commitment to protect our investment in Scotland," it said.
It went on: "Communities worldwide continue to challenge the destructive proliferation of wind turbines and we will remain a fierce opponent at the forefront of this battle.
"Despite today's decision, the EOWDC proposal has numerous economic and legal obstacles that will ultimately prevent its construction."
Environmental campaigners were of one voice in welcoming Lord Doherty's decision.
Mr Trump has previously said he will pull the plug on his own controversial plans to finish his proposed resort at Menie Estate, near Balmedie, with a large hotel, holiday homes and a residential village, if the windfarm goes ahead.
The offshore project was put together by Vattenfall Wind Power and Aberdeen Renewable Energy Group.
Under the plan, the turbines will have an installed capacity of up to 100MW and over one year would be capable of yielding, on average, enough electricity to power 68,000 UK households, according to the group behind the project.
Trump International and The Trump Organisation, known as the petitioners in this case, challenged the decisions not to hold a public inquiry and to give the project the green light on several grounds.
They argued that ministers had no power to grant the consent and that doing so was "irrational".
The petitioners also maintained that for various reasons, including certain remarks said to have been made by the First Minister, a fair-minded person would conclude that there was a real possibility of bias on the part of the decision-maker.
They argued that a decision not to hold a public inquiry in relation to the planned project was "unreasonable" and further claimed their rights under the European Convention on Human Rights (ECHR) had been breached.
But the judge rejected the legal bid.
A summary of the opinion issued by the Judiciary of Scotland stated: "Lord Doherty dismissed the petition."
It went on: "He was not persuaded that the fair-minded and informed observer would conclude that there was a real possibility of bias on the part of the decision-maker; or that the decision not to have a public inquiry had been unreasonable or unlawful."
He further ruled that the petitioners' rights had not been breached and was satisfied that Energy Minister Fergus Ewing "was entitled to grant consent subject to the conditions which he imposed".
Welcoming the ruling, a Scottish Government spokeswoman said: "Scottish ministers are pleased that the court has found in their favour.
"The proposed European Offshore Wind Deployment Centre is an important project for Aberdeen and north-east Scotland. It will give the industry the ability to test and demonstrate new technologies to accelerate its growth.
"Aberdeen is already of global importance for hydrocarbons and this wind deployment centre cements its role in renewable offshore development, further positioning Aberdeen as the energy capital of Europe and a world energy centre."
Green MSP Patrick Harvie, who has long campaigned against Mr Trump's controversial golf resort development, said: "Donald Trump is a man who actually peddles the paranoid fantasy that climate change is a communist conspiracy. Scotland can't afford to waste another second on him."
WWF Scotland director Lang Banks said: "This result is great news for Scotland and for all those interested in cutting climate emissions and creating jobs.
"It's good to know that despite all his bluster, the courts saw right through Trump's flimsy, misguided attempts to frustrate Scotland's ambition to create clean power and green jobs."
RSPB Scotland and Friends of the Earth Scotland also welcomed the court's ruling.