The detection of planetary transits in stellar photometric light-curves is poised to become the main method for finding substantial numbers of terrestrial planets . The French-European mission COROT ( foreseen for launch in 2005 ) will perform the first search on a limited number of stars , and larger missions Eddington ( from ESA ) and Kepler ( from NASA ) are planned for launch in 2007 . Transit signals from terrestrial planets are small ( \Delta F / F \simeq 10 ^ { -4 } ) , short ( \Delta t \simeq 10 hours ) dips , which repeat with periodicity of a few months , in time series lasting up to a few years . The reliable and automated detection of such signals in large numbers of light curves affected by different sources of noise is a statistical and computational challenge . We present a novel algorithm based on a Bayesian approach . The algorithm is based on the Gregory-Loredo method originally developed for the detection of pulsars in X-ray data . In the present paper the algorithm is presented , and its performance on simulated data sets dominated by photon noise is explored . In an upcoming paper the influence of additional noise sources ( such as stellar activity ) will be discussed .