The official with the Malaysian Maritime Enforcement Agency said the boat carrying around 80 people overturned and sank late Monday as a patrolling vessel was pursuing it off the state of Johor.
"The boat carried illegal immigrants going back to Indonesia" to celebrate the end of Ramadan, the official told AFP, adding that 59 people had been rescued.
"The boat was small and... overloaded," said the official, who requested anonymity as he was not authorised to speak to the media.
He said the bodies of a man and a woman had so far been recovered.
Boat accidents are common as Malaysia draws hundreds of thousands of illegal immigrants from poorer neighbouring countries.
Authorities have stepped up patrols during Ramadan as many from Indonesia seek to sneak out and return in rickety boats to celebrate the end of the fasting month.
More than a dozen people died and about two dozen others went missing last month in two boat accidents in rough weather off Malaysia's west coast.