A panel of three judges at the Court of Session found in favour of a cross-party group of politic who were challenging the Prime Minister's move, the BBC reported on Wednesday.
The judges said the Prime Minister was attempting to prevent Parliament from holding the government to account ahead of Brexit.
The UK government said it will appeal against the ruling in the Supreme Court in London.
The Court of Session decision overturns an earlier ruling from the court which said last week that Johnson had not broken the law.
But it will not immediately affect the current suspension of Parliament, which started in the early hours of Tuesday.
This is because no order has been given by the court to cancel the suspension ahead of a full hearing at the Supreme Court in London which starts Tuesday next week.
MPs are not currently scheduled to return to Parliament until October 14, when there will be a Queen's Speech outlining Johnson's legislative plans. The UK is due to leave the European Union on October 31.
In a summary of their findings, the Court of Session judges said they were unanimous in their belief that Johnson was motivated by the "improper purpose of styming Parliament".
"The court will accordingly make an order declaring that the Prime Minister's advice to the Queen and the prorogation which followed thereon was unlawful and is thus null and of no effect," they added.
The group of more than 70 largely pro-Remain MPs and peers behind the legal challenge were headed by Scottish National Party MP Joanna Cherry, who has called for Parliament to be immediately reconvened following the ruling.
They appealed to the Inner House of the Court of Session after their original challenge to the suspension of Parliament was dismissed by judge Lord Doherty last week.
Lord Doherty said Johnson had not broken the law by proroguing Parliament, and that it was for the MPs and the electorate to judge the Prime Minister's actions rather than the courts.
But the three Inner House judges said they disagreed with Lord Doherty's ruling because this particular prorogation had been a "tactic to frustrate Parliament".
One of the three judges, Lord Brodie, said: "It was to be inferred that the principal reasons for the prorogation were to prevent or impede Parliament holding the executive to account and legislating with regard to Brexit, and to allow the executive to pursue a policy of a no-deal Brexit without further Parliamentary interference."
Lord Drummond Young said the UK government had failed to show a valid reason for the prorogation, adding: "The circumstances, particularly the length of the prorogation, showed that the purpose was to prevent such scrutiny.
"The only inference that could be drawn was that the UK government and the prime minister wished to restrict Parliament."
The judges will release their full findings on Friday.
In a separate case brought by anti-Brexit campaigner Gina Miller, the High Court in London also ruled last week that Johnson had acted lawfully. Miller is appealing that decision in the Supreme Court.
( With inputs from IANS )