The crash of a train into a low-rise apartment building in Sweden this week was an accident and not the fault of a cleaner, state prosecutors have said.

On Tuesday, a train ploughed past the end of the line at a depot, vaulted a narrow side-street and crashed into an apartment block in the upscale Stockholm suburb of Saltsjobaden.

The cleaner was the only person hurt in the incident and she had initially been suspected of committing a crime.

However, the state prosecution service said that there is no longer anything that indicates that the woman drove the train away on purpose.

An order for her detention has been lifted.

"Several circumstances point now to the fact that the train began moving due to an accident," the state prosecution service said in a statement.

The service said it had found serious breaches of security on the train.

Prosecutors began investigating the case as one of endangering the public, but that might now be changed to one of a breach of laws on working conditions, the prosecution service said.