In a ruling that may affect foreclosures nationwide, Massachusetts' highest court voided the seizure of two homes by Wells Fargo & Co and US Bancorp after the banks failed to show they held the mortgages at the time they foreclosed.

Bank shares fell, dragging down the broader U.S. stock market, after the Supreme Judicial Court of Massachusetts on Friday issued its decision, which upheld a lower court ruling.

The decision is among the earliest to address the validity of foreclosures conducted without full documentation. That issue last year prompted an uproar that led lenders such as Bank of America Corp, JPMorgan Chase & Co and Ally Financial Inc to temporarily stop seizing homes.

Courts in other U.S. states are considering similar cases, and all 50 state attorneys general are examining whether lenders are forcing people out of their homes improperly.

Friday's decision may also threaten banks' ability to package mortgages into securities, including whether loans that were transferred improperly might need to be bought back.

Wells Fargo and U.S. Bancorp lacked authority to foreclose after having failed to make the required showing that they were the holders of the mortgages at the time of foreclosure, Justice Ralph Gants wrote for a unanimous court.

Wells Fargo was not immediately available for comment. U.S. Bancorp spokesman Steve Dale said the ruling has no financial impact on the bank, which has no responsibility for the terms of the underlying mortgage or the procedure by which they were transferred into a mortgage trust.

What they were doing was peddling these mortgages and leaving the paperwork behind, said Michael Pill, a partner at Green, Miles, Lipton & Fitz-Gibbon LLP in Northampton, Massachusetts, who represents homeowners and is not involved in the case.

In early afternoon trading, Wells Fargo shares were down nearly 4 percent at $30.92, while U.S. Bancorp was down 1.4 percent at $25.93.

Bank of America stock was down 2.8 percent, JPMorgan fell 3.7 percent, and the KBW Bank Index, which includes all four lenders, was down 2.3 percent. Major U.S. stock indexes were down 0.6 percent to 0.8 percent.

'UTTER CARELESSNESS'

In the Massachusetts case, U.S. Bancorp and Wells Fargo had said they controlled through different trusts the respective mortgages of Antonio Ibanez as well as Mark and Tammy LaRace, who lost their homes to foreclosure in 2007.

The banks bought the homes in foreclosure, and sought court orders confirming they had title. A lower court judge ruled against them, and Friday's decision upheld this ruling.

In a concurring opinion, Justice Robert Cordy lambasted the utter carelessness that Wells Fargo and US Bancorp demonstrated in documenting their right to own the properties.

Massachusetts is one of 27 U.S. states that do not require court approval to foreclose.

Gants did suggest in his opinion how banks might properly transfer mortgages via securitization trusts.

The executed agreement that assigns the pool of mortgages, with a schedule of the pooled mortgage loans that clearly and specifically identifies the mortgage at issue as among those assigned, may suffice to establish the trustee as the mortgage holder, Gants wrote. However, there must be proof that the assignment was made by a party that itself held the mortgage.

The cases are U.S. Bank N.A. v. Ibanez and Wells Fargo Bank NA v. LaRace et al, Massachusetts Supreme Judicial Court, No. SJC-10694.

(Reporting by Jonathan Stempel and Dena Aubin; Editing by Lisa Von Ahn and Matthew Lewis)