We extend the recently proposed ab initio no-core shell model with continuum to include three-nucleon (3N) interactions beyond the few-body domain. The extended approach allows for the assessment of effects of continuum degrees of freedom as well as of the 3N force in ab initio calculations of structure and reaction observables of p- and lower-sd-shell nuclei. As first application we concentrate on energy levels of the 9Be system for which all excited states lie above the n-8Be threshold. For all energy levels, the inclusion of the continuum significantly improves the agreement with experiment, which was an issue in standard no-core shell model calculations. Furthermore, we find the proper treatment of the continuum indispensable for reliable statements about the quality of the adopted 3N interaction from chiral effective field theory. In particular, we find the 1/2+ resonance energy, which is of astrophysical interest, in good agreement with experiment.