Gun owners will next year be able to legally carry handguns in dorms, classrooms and buildings in public universities in Texas under a bill expected to be signed by the governor within several days.

The measure was passed by the state’s legislature Sunday night and will go to Texas Gov. Greg Abbott, who has said he would sign it.

Of the 15...