Two people, including a police officer, died when a gunman opened fire near a college campus in Texas on Monday.

Texas A&M University reported on its website that the shooter is in custody, having earlier warned students to remain inside.

Meanwhile Rhonda Seaton of the College Station police department told CNN that several people were shot in the incident, including law enforcement officers.

Police later confirmed that one officer and one other person had died and several more were injured.

The extent of their injuries was not immediately known.

An initial "code maroon" alert was sent out by college officials shortly before 12.30pm local time, warning students of an active shooter in an intersection close to campus.

"Please avoid the area. Residents in the immediate area need to remain in their residence," it stated.

At 12.44pm another message was posted confirming that the gunman had been taken into custody.

Speaking to the Guardian, Seaton said: "Officers were called to respond to an active shooting. We have multiple injuries including to law enforcement officers.

"The situation is now under control."

She added: "At this time we believe there was only one suspect and that person has been detained."

The campus police officer could not confirm how many people were shot and said she did not know the extent of their injuries.