The shelling of a U.N. school housing thousands of refugees brought widespread condemnation against Israel, which said it fired at militants nearby.