It's important to note that Israel was founded the same day the Arab armies declared their invasion. However, it's even more important to note that hostilities in the form of a civil war had already been undergoing from late-1947 or so, after the UN Partition Plan was passed by the UN General Assembly.
A version of this question was actually asked here, and /u/smileyman's response details it very succinctly as far as how they managed to succeed.
Also important to note is that the Arab countries surrounding had already contributed arms and fighters to the conflict before the invasion through the Arab Liberation Army.
You may find this post on the run-up to the invasion (and the civil war) interesting as well, since it will cover much of what you are asking.
Finally, I'd like to point out that Israel had mostly defeated the Palestinians before the Arabs invaded. However, the Israelis had known the Arabs were going to declare war, and even got troop estimates (overestimated ones, at that) 3 days before the invasion. Still, the Arabs had the initial advantage of tactical advantage, but that's not to say Israel was unprepared, just that the Arab plans for action gave them initiative.
I'd highly recommend Benny Morris's 1948: The First Arab-Israeli War for more information!