A Brooklyn man who forced his way into the Stony Brook University campus was found guilty of menacing and criminal possession of a weapon on school grounds and now faces as much as 5 years in prison, prosecutors said Tuesday.

After going into the Social and Behavioral Sciences Building on campus on Oct. 4, 2014, Joseph Lloyd, 32, confronted his former girlfriend and threatened her with a silver .38 Smith & Wesson handgun, Suffolk County District Attorney Thomas Spota said in a news release.

Lloyd demanded to see his former girlfriend’s cellphone and checked it before fleeing, the release said. But his forcible entry had prompted a 911 call to the university police force.

University police chased him from the Stony Brook Long Island Rail Road platform into a wooded area near the athletic field, where they arrested him.

advertisement | advertise on newsday

The police also recovered a handgun he had tossed on the ground while they were pursuing him, the release said.

The jury deliberated for two hours after reaching a verdict in the trial before State Supreme Court Justice John Collins that began on Sept. 19, Spota said.

Lloyd is scheduled to be sentenced on Oct. 27.