Edible microalgae have potential as low-cost cell factories for the production and oral delivery of recombinant proteins such as vaccines, anti-bacterials and gut-active enzymes that are beneficial to farmed animals including livestock, poultry and fish. However, a major economic and technical problem associated with large-scale cultivation of microalgae, even in closed photobioreactors, is invasion by contaminating microorganisms. Avoiding this requires costly media sterilisation, aseptic techniques during setup and implementation of 'crop-protection' strategies during cultivation. Here, we report a strain improvement approach in which the chloroplast of Chlamydomonas reinhardtii is engineered to allow oxidation of phosphite to its bioavailable form: phosphate. We have designed a synthetic version of the bacterial gene (ptxD)-encoding phosphite oxidoreductase such that it is highly expressed in the chloroplast but has a Trp→Opal codon reassignment for bio-containment of the transgene. Under mixotrophic conditions, the growth rate of the engineered alga is unaffected when phosphate is replaced with phosphite in the medium. Furthermore, under non-sterile conditions, growth of contaminating microorganisms is severely impeded in phosphite medium. This, therefore, offers the possibility of producing algal biomass under non-sterile conditions. The ptxD gene can also serve as a dominant marker for genetic engineering of any C. reinhardtii strain, thereby avoiding the use of antibiotic resistance genes as markers and allowing the 'retro-fitting' of existing engineered strains. As a proof of concept, we demonstrate the application of our ptxD technology to a strain expressing a subunit vaccine targeting a major viral pathogen of farmed fish.