Graphene has been considered as an attractive material for optoelectronic applications such as photodetectors owing to its extraordinary properties, e.g. broadband absorption and ultrahigh mobility. However, challenges still remain in fundamental and practical aspects of the conventional graphene photodetectors which normally rely on the photoconductive mode of operation which has the drawback of e.g. high dark current. Here, we demonstrated the photovoltaic mode operation in graphene p-n junctions fabricated by a simple but effective electron irradiation method that induces n-type doping in intrinsic p-type graphene. The physical mechanism of the junction formation is owing to the substrate gating effect caused by electron irradiation. Photoresponse was obtained for this type of photodetector because the photoexcited electron-hole pairs can be separated in the graphene p-n junction by the built-in potential. The fabricated graphene p-n junction photodetectors exhibit a high detectivity up to ~3 × 1010 Jones (cm Hz1/2 W−1) at room temperature, which is on a par with that of the traditional III–V photodetectors. The demonstrated novel and simple scheme for obtaining graphene p-n junctions can be used for other optoelectronic devices such as solar cells and be applied to other two dimensional materials based devices.