Counting the Omer during Twilight

(א) סדר תפל' ליל שני של פסח וספירת העומר. ובו י"ס:
בליל שני אחר תפל' ערבית מתחילין לספור העומר ואם שכח לספור בתחל' הלילה הולך וסופר כל הלילה ומצוה על כל אחד לספור לעצמו וצריך לספור מעומד ולברך תחל' וסופר הימים והשבועו' כיצד ביום הראשון אומר היום יום אחד (בעומר) עד שמגיע לשבעה ימים ואז יאמר היום שבעה ימים שהם שבוע אחד (בעומר) וביום שמיני אומר היום שמונה ימים שהם שבוע א' ויום א' (בעומר) וכן עד שיגיע לארבע' עשר יאמר היום ארבעה עשר ימים שהם שני שבועו' (בעומר) ועל דרך זה מונה והולך עד מ"ט יום:

(ב) אם טעו ביום המעונן ובירכו על ספירת העומר חוזרים לספור כשתחשך והמדקדקים אינם סופרים עד צאת הכוכבים וכן ראוי לעשות:

(1) On the second night after the evening prayer, we begin to count the Omer. And if someone forgot to count, [that one may count] from the beginning of the evening onwards. He may count all night. It is a mitzvah for each person to count for themselves. He needs to count standing and bless before. He should count the days and weeks. How? On the first day he should say “today is day one of the Omer”, until he arrives to seven days. [At which point he should say], “they are one week of the Omer.” And on the eighth day he should say “today is eight days and they are one week and one day of the Omer.” And also, when he arrives to the 14th day, he should say “today is 14 days, they are two weeks of the Omer.” And in this way he should count and onwards until the 49th day.

(2) If they (the people who are counting) made a mistake on a cloudy day and they blessed on the counting of the Omer, they should go back to count when it got dark. Those who are punctilious, they do not count until the stars come out [namely, three stars], and this is a proper thing to do.

זכר למקדש הוא. נראה דבספק חשיכה יכול לברך ואין צריך להמתין עד שיהא ודאי לילה כיון שהוא ספיקא דרבנן

It seems that during the period of possible nighfall, one may [count the sefira and] make the blessing. There is no need to wait until it is certainly nightfall, since we are dealing with a rabbinic doubt...

Rabbeinu Nissim of Gerona , 14th cent. commentary to the Rif

The rule of safek brachot l'hakel applies only after the fact, in situations where one performed the act and then a question arose as to whether or not the act satisfactorily fulfilled the rabbinic obligation. ...one must wait until absolute nightfall before counting the omer, in order to avoid uncertainty. It is only if one mistakenly counted the omer during twiligh that we may then apply the rule of safeik de-rabbanan le-hakel to absolve him of the need to count again after dark.

(ז) אם טעו ביום המעונן וספרו ביום, ובירכו "על ספירת העומר" – חוזרים לספור כשתחשך בברכה, דספירת היום על יום דלמחר – אינו כלום. ולכן המדקדקים אינן סופרין עד צאת הכוכבים, וכן ראוי לעשות.ואם ספרו אחר השקיעה בבין השמשות – יצא...ואין אנו סומכין לספור בין השמשות רק בקבלת שבת, משום דמצוה וחובה לקבל שבת בעוד יום.

(ח) כתב רבינו הבית יוסף בסעיף ג:המתפלל עם הציבור מבעוד יום – מונה עמהם בלא ברכה. ואם יזכור בלילה – יברך ויספור.עד כאן לשונו. ולאו דווקא מבעוד יום, דאם כן היאך מברכין הציבור ברכות לבטלות? ולמה ימנה עמהם לחזק ידי עוברי עבירה? ועוד: למה קאמר "ואם יזכור" – הלא מחוייב לזכור, שהרי לא יצא כלל.אלא הכוונה שאין עדיין לילה ממש, אלא בין השמשות דמותר לספור אז, כמו שכתבתי. אך הוא אינו רגיל לספור אלא בלילה. ולכן יספור עמהם בלא ברכה, ויכוין שאם לא יזכור – יצא בספירה זו. ואם יזכור – לא יצא. ותנאי מועיל בכי האי גוונא. וזהו שסיים רבינו הרמ"א, וזה לשונו:ואפילו ענה "אמן" על ברכת הציבור, אם היה דעתו שלא לצאת – יחזור ויברך ויספור בלילה.עד כאן לשונו, וזהו כדברינו.

7. If one made an error on a cloudy day and made the blessing, one should repeat again once it is certainly nightfall and count again, with a blessing. For counting the omer on the day to come is an irrelevant action. Therefore, the punctilious will not count until certain nightfall, which we strive to do. But if one did count after sunset but before nightfall, they have fulfilled their obligation.

We do not consider twilight as the following day, except for Kabbalat Shabbat [which we routinely bring in prior to nightfall]. This is because there is a mitzvah to bring in Shabbat while there is still daylight.

8. The Beit Yosef writes: "one who davens with the community while it is still daytime - should count the omer with them, but not make a blessing. And if he remembers later that night - he should repeat the counting with a blessing." Now, this cannot possibly mean actual daytime, for how could it be that the community is collectively making an empty bracha? And why should he count with them, thereby seeming to justify their practice? And furthermore, why would he say if he remembers - he's obligated to remember, as he hasn't yet fulfilled the mitzvah!

Therefore, he must be referring to twilight, when it is permissible to count, as we have said. And he's discussing a person who typically only counts at night, so he may count here without a blessing with the intention that if he fails to count again after nightfall, he has nevertheless fulfilled his obligation with this counting. One may make a mental stipulation regarding this.

The Rema concludes: "and even if he answered amen to the congregation's blessing, if he had in mind not to fulfill his obligation until later, he may indeed do so with a blessing.