This article is intended to evaluate the probabilities of occurrence of mainshocks immediately after the occurrence of possible foreshocks and propose an optimal prediction algorithm based on possible foreshocks along the Japan and Kuril trenches and also to investigate the regional variation of foreshock activity in that region. Every earthquake or earthquake cluster defined specifically, except for small aftershocks, is treated as a possible foreshock. The parameters for defining possible foreshocks are magnitude (Mf), the size of square segment [D° (latitude) × D° (longitude)], time interval (Tf), and the number of earthquakes (Nf) having occurred in that space-time. However, Tf is fixed at 10 days in this study. The expected space of mainshocks to occur is defined as the segment where proposed foreshocks have occurred, and the expected time interval (Ta) is varied as a parameter. To estimate the probabilities of occurrence of mainshocks with magnitude ≧Mm0 after the occurrence of possible foreshocks, the following three indices, alarm rate (AR), truth rate (TR), and probability gain (PG) are adopted. The parameters of Nf, Mf, D, and Ta have a significant effect on evaluating the probabilities. The optimal values of parameters for possible foreshocks, which may provide us with a totally performed prediction algorithm, are estimated on the basis of the Precursor Information Criterion (PIC) by using the Japan Meteorological Agency (JMA) hypocenter catalog data from 1980 to 1993. The estimated values are Mf ≧ 5, Nf = 3, Ta = 5 days, and D = 0.5° for mainshocks with magnitude ≧6, which give a set of values of 13%, 25%, 617, and 75 to AR, TR, PG, and PIC, respectively; and Mf ≧ 4, Nf = 1, Ta = 1 day, and D = 0.25° for mainshocks with magnitude ≧5, which give values of 9%, 0.8%, 56, and 220 to the same indices as above. Moreover, it is found by using the data from 1926 to 1993 that there is a strong regional variation of foreshock activity; that is, four regions exhibit high activity of foreshocks, and the deeper the hypocenter of the mainshock, the smaller the percentage of mainshocks preceded by foreshocks.