They told the militants "to kill them together or leave them alone", a local governor told Kenyan media.
At least two people were killed in the attack, near the north-eastern village of El Wak on the Somali border.
The Somali based al-Shabab group is the main suspect for the attack.
It has not said if it was responsible, but often carries out attacks in Kenya's north-east.
The bus was travelling from the capital Nairobi to the town of Mandera.
When al-Shabab killed 148 people in an attack on Garissa University College in April, the militants reportedly singled out Christians and shot them, while freeing many Muslims.
Last year, a bus was attacked near Mandera by al-Shabab militants, who killed 36 non-Muslims travelling to Nairobi for Christmas celebrations.
"The locals showed a sense of patriotism and belonging to each other," Mandera governor Ali Roba told Kenya's private Daily Nation newspaper.
The militants decided to leave after the passengers' show of unity, he added.
An employee of the Makkah bus company, who had spoken to the driver involved in the attack, confirmed to the BBC that Muslims had refused to be separated from their fellow Christian passengers.
One of the victims was shot dead after trying to run away from the militants after passengers had been forced off the bus, the same employee told the BBC's Bashkas Jugsodaay in Nairobi.
Al-Shabab has been at war with Kenya ever since Kenyan forces entered Somalia in October 2011 in an effort to crush the militants.
Kenya's north-eastern region has a large population of ethnic Somalis.
A group of Kenyan Muslims travelling on a bus ambushed by Islamist gunmen protected Christian passengers by refusing to be split into groups, according to eyewitnesses.