No crew member was harmed when the pirates entered the barge armed with machetes. The men boarded the Malaysian vessel off Sarawak state on Thursday.
The crew locked themselves inside the tugboat and raised the alarm, Abim Sungom of the Malaysian Maritime Enforcement Agency said.
Later, four pirates were detained by the authorities from the barge which was carrying containers.
Though the crew of four Indians, four Malaysians, and two Indonesians was not injured but some valuables, including mobile phones and cash, were stolen.
The vessel was heading from peninsular Malaysia to Borneo island.