Image copyright AFP Image caption The patent row between Apple and Samsung began in 2011

The US Supreme Court has sided with Samsung in the South Korean company's long-running patent fight with Apple.

The court rejected an earlier ruling that Samsung must pay $399m to Apple for copying some iPhone designs.

At issue was how much Samsung must compensate Apple under a 1887 law that patent infringers pay "total profits".

The top US court ruled that paying all profits was wrong, as the features at issue in the Samsung phones formed only a small part of the devices.

However, the dispute is not over. The case now returns to a lower court to decide the amount of compensation that Samsung should pay.

The Supreme Court's unanimous decision followed a legal battle between the world's top two smartphone manufacturers that began in 2011 when Apple sued Samsung, asserting that its rival stole its technology and the iPhone's trademarked appearance.

Samsung had been seeking to pare back the money it paid Apple in December following a 2012 jury verdict that it infringed Apple's iPhone patents and copied its distinctive appearance.

After the trial, Apple was awarded nearly $930m in damages. In May 2015, a US appeals court upheld the patent infringement verdict, but said the iPhone's appearance could not be protected through trademarks. As a result, the court reduced Samsung's payment.

Samsung had argued that the size of the penalty ignored the fact that its phones contain more than 200,000 other patents that Apple did not own.

Apple claimed that Samsung should pay because the iPhone's success was directly tied to its distinctive look.