The backpackers from Britain, Canada and the Netherlands -- were arrested after stripping naked on May 30 and posing for photos on the mountaintop.
The mountain is considered sacred in Malaysia.
They had pleaded guilty to "committing an obscene act."
The 2 Canadians have been identified as as Lindsey and Danielle Peterson. The Briton is named Eleanor Hawkins but the name of the Dutchman has not yet been confirmed.
The court in Kota Kinabalu on Friday evening fined the 4 tourists 5,000 Malaysian ringgits, about $1,332, each and sentenced them to three days in prison. Taking into account the time served already, the court ordered them freed.
Local residents had said their behavior caused the Kota Kinabalu earthquake this month, which killed 16 people. The indigenous people of Sabah believe the tourists disrespected local culture and angered the spirit of the mountain.
Among those who appeared in court was a British citizen who was arrested at the airport this week as she was about to leave for the capital of Kuala Lumpur.
The other three turned themselves in. They could have faced three months in prison.