A gunman has shot dead a police officer on the campus of the prestigious Massachusetts Institute of Technology near the US city of Boston, according to authorities.

The university warned students to stay indoors late Thursday, and a major hunt was launched for the gunman. Police with rifles were in the streets, and search helicopters flew above the university.

"The shooter remains at large, police continue to search the campus. Please remain indoors until further notice," said an emergency alert issued by the university on its website two hours after the shooting.

AFP news agency reported that witnesses heard gunfire and explosions in streets close to MIT on Friday. Local media has said one person may have been shot in the battle.

The NBC-WJAR channel later showed film of a man lying on the ground in a street in the town and surrounded by police.

MIT is in Cambridge, Massachusetts, just across the Charles River from Boston, where three people were killed and 180 injured in a double bomb attack on the city's marathon on Monday. Authorities made no immediate link between the two incidents.

The MIT campus police officer suffered "multiple gunshot wounds" when he responded to a disturbance, said Middlesex District Attorney Michael Pelgro in a statement.

The officer "was transported to the hospital and pronounced deceased," said the statement, which added that there were no other victims.

Police cordoned off a large area of the university and surrounding streets as part of the emergency. Local trains running from Cambridge to Boston were all searched by police.

MIT has about 11,000 students and is considered one of the world's leading universities.