Police and soldiers surrounded the campus at the Garissa University College and were attempting to flush out the gunmen, Joseph Boinet, Kenya's inspector general, said in a statement.
"The attackers shot indiscriminately while inside the university compound," he said. The gunmen may have taken hostages, a policewoman at the scene told Reuters.
Most of the wounded had been hit by gunfire and four were in a critical condition, the country's National Disaster Operation Centre said on its Twitter feed.
"I can tell you that we have 49 casualties so far, all with bullet and (shrapnel) wounds. Four people are dead and have bullet wounds as well," said a doctor at Garissa hospital.
No group claimed responsibility for the raid.
Somali Islamist militant group al Shabaab, which has links to Al Qaeda, has carried out several attacks in Garissa and across Kenya in the past.
Grace Kai, a student at Garissa Teachers Training College which neighbours the campus that was attacked, said there had been warnings that an attack could be imminent.
"Some strangers had been spotted in Garissa town and were suspected to be terrorists," she told Reuters.
"Then on Monday our college principal told us ...that strangers had been spotted in our college... On Tuesday we were released to go home, and our college closed, but the campus remained in session, and now they have been attacked."
Al Shabaab, which was responsible for an deadly attack in 2013 on the upscale Westgate shopping mall in Nairobi, has vowed to punish Kenya for sending troops into Somalia alongside African Union peacekeepers to fight the group.