When the Jews are sandwiched between the Egyptian army and the sea, the Torah tells us that the people cried out to Hashem, but at the same time protested about Moshe having taking them out of Egypt. This incident seems very strange because of the inherent contradiction. If the Jews were calling to Hashem, they must have thought Hashem would save them. But then why would they complain that Hashem took them out of Egypt? The Ramban (commenting on Shemot 14:10-12) answers that there were two groups within Bnei Yisrael at that point. One group cried out to Hashem, while the other protested against Moshe having taken the Jews out of Egypt. This is alluded to in Tehilim: “They were rebellious at the sea, even at the Red Sea” (106:7).
The Ramban states further that whenever the Chumash uses the term “the children of Israel,”, it is referring to the righteous group among Am Yisrael. This is why the Chumash in this Parsha says, “And the children of Israel lifted up their eyes…and the children of Israel called out unto the Eternal” (14:10). This is saying that the better ones called out, and the rest rebelled. If so, we must ask why the Torah, after the Yam Suf was split, states (14:31), “And the people feared the Eternal; and they believed in the Eternal and His servant Moshe.” The answer is that it says “the people,” not “Bnei Yisrael” teaching that after the great miracle even the rebellious group was moved to belief in Hashem.
This idea expressed several times elsewhere in Chumash, such as in the Pasuk, “And the people murmured” (15:24). It also uses the term “the people” during the sin of Baal Peor in Shittim (see Bemidbar 25:1). We can see from these cases that whenever the Chumash uses the term “the people,” it refers to rebels, and when the Chumash uses the term “the children of Israel,” it refers to a group of believing Jews.
We can suggest a second explanation to resolve the contradiction. During the complaint at the Yam Suf, Bnei Yisrael complained to Moshe and said (14:11), “Have you taken us to die in the wilderness!?” This shows that even before the people were scared of war, they were already scared of dying from hunger and thirst. It is possible to say that the people did believe in Hashem but doubted Moshe. Perhaps he had brought them out of Egypt to rule over them. And as for the wonders that he performed, maybe he did it through his wisdom; maybe the Makkot were simply from Hashem to punish the Egyptians for their wickedness, and not to take them out of Egypt. They supported their claim with a “proof”: if all if it was from Hashem, then why did the Egyptians pursue them even after they had left Egypt? Accordingly, this appears to be the reason why the Torah states that after the Yam Suf was split we believed in both Hashem and Moshe His servant.
An additional interpretation can be found in the Mechilta, which states that the People of Israel had prayed to Hashem properly as their fathers did. Subsequently, the Midrash adds, after they “added leaven to the Matzah”, they asked Moshe (14: 11), “Is it because were there no graves in Egypt that you have taken us to die in the wilderness?” The leaven dough is a reference to the Yetzer Hara. Bnei Yisrael cried to Hashem to save them from the Egyptians, and after they saw that Pharaoh did not turn around, they followed their Yetzer Hara and started to complain to Moshe.