University of Maryland students were confronted by robbers Sunday in two separate incidents that occurred steps from the College Park campus. A student was beaten in one incident, and what was believed to be a replica of a gun was involved in the other.

The first incident occurred about 3 a.m. outside a restaurant in a commercial strip just south of campus in the 7400 block of Baltimore Avenue. Robbers punched a student with brass knuckles, according to accounts from campus and Prince George’s County police.

The assailants went through the student’s pockets and took his wallet and smartphone, campus police said.

As county police arrived, they saw three people run from the scene. They were taken into custody and charged with armed robbery and first-degree assault, police said. Two are teenagers, and the other is 20 years old. Police said all three live within a few miles of campus.

The student was treated at the scene for minor injuries to the head and face, authorities said. They added that his phone was recovered.

The second incident occurred several blocks north about 1:15 p.m. in an apartment house built for students just off campus in the 8100 block of Baltimore Avenue.

Police said a would-be robber approached a student in a common area of the building, known as the Varsity.

The man displayed what county police said was believed to be a fake handgun.

He demanded the student’s laptop computer, and a scuffle began when the student refused to surrender it, according to campus police.

A witness intervened and tried to stop the fight. The robber fled. No injuries were reported.