Al-Shabab claimed responsibility for the attack through its radio station in Somalia, saying it was in retaliation for raids by Kenyan security forces carried out earlier this week on four mosques at the Kenyan coast.
Nineteen men and nine women were killed in the bus attack, said Kenyan police chief David Kimaiyo.
The bus traveling to the capital Nairobi with 60 passengers was hijacked about 50 kilometers (31 miles) from the town of Mandera near Kenya's border with Somalia, said two police officers.
The two officers said the bus was first waved down but it didn't stop so the gunmen sprayed it with bullets and when that didn't work they shot a rocket propelled grenade at it, the officers said.
The gunmen commandeered the bus off the road and ordered all the passengers out of the vehicle and separated those who appeared to be non-Muslims from the rest and shot them at close range, the officers said.
The police insisted on anonymity because Kenya's police chief ordered that officers should not speak to the press.
Some of the dead were public servants who were heading to Nairobi for the Christmas vacation, the officers said.
A shortage of personnel and lack of equipment led to a slow response by police when the information was received, the officers said. They said the attackers have more sophisticated weaponry than the police who waited for military reinforcements before responding.
Kenya has been hit by a series of gun and bomb attacks blamed on al-Shabab, who are linked to Al Qaeda, since it sent troops into Somalia in October 2011. Authorities say there have been at least 135 attacks by al-Shabab since then, including the assault on Nairobi's upscale Westgate Mall in September 2013 in which 67 people were killed. Al-Shabab said it was responsible for other attacks on Kenya's coast earlier this year which killed at least 90 people.
Kenyan troops are part of the African Union Mission in Somalia which is bolstering Somalia's weak U.N.-backed government against the al-Shabab insurgency. Al-Shabab has continued to carry out attacks in Somalia's capital despite being pushed out of Mogadishu in August 2011. Somali government troops backed by AU forces are making progress in seizing the remaining al-Shabab strongholds. Recently, they captured the port town of Barawe.
Al-Shabab was also dealt a heavy blow when their leader, Ahmed Abdi Godane, was killed in early September by a U.S. airstrike. Godane has been replaced by Ahmed Omar, also known as Abu Ubeid.
Kenya has been struggling to contain growing extremism in the country. Earlier this week the authorities shut down four mosques at the Kenyan coast after police alleged they found explosives and a gun when they raided the places of worship.
Some Muslims believe the police planted the weapons to justify closing the mosques, Kheled Khalifa, a human rights official said Friday warning that methods being used to tackle extremism by government will increase support for radicals.
One person was killed during the raid on two of the mosques on Monday. Police said they shot dead a young man trying to hurl a grenade at them.
The government had previously said the four mosques were recruitment centers for al-Shabab.