OTTAWA -- The Supreme Court says Canadians can expect the text messages they send to remain private -- at least in some instances -- even after the messages reach their destination.

In a potentially significant 5-2 ruling today, the high court set aside the firearms convictions of a man whose messages were found by Toronto police on the mobile phone of an alleged accomplice.

The court says Nour Marakah had a reasonable expectation of privacy concerning the messages, meaning he had a right to challenge the police search of the phone as a violation of his guarantees under the Charter of Rights and Freedoms.

In her reasons for the majority, Chief Justice Beverley McLachlin notes that Marakah was the author of the text messages introduced as evidence against him, that he expected the electronic conversation to remain private and that he asked the recipient numerous times to delete the messages.

However, the court cautions that much depends on the facts of a case, and that the outcome might be different in other circumstances.

In addition, McLachlin says that even if an accused person has the right to argue there was a violation of their constitutional right against unreasonable search and seizure, it does not mean that the argument will succeed.

She also writes that not every kind of electronic communication will involve a reasonable expectation of privacy that allows an accused to make the charter argument.

"This case does not concern, for example, messages posted on social media, conversations occurring in crowded internet chat rooms, or comments posted on online message boards."

In a second ruling today, the Supreme Court dismissed an appeal of gun and drug convictions in a case where Ottawa police had a production order to seize text messages stored on a Telus server.