The title is a little bit misleading—baseball wasn't invented in a single stroke of brilliance, but rather evolved over time. A version of the game was likely played in Europe even before the first American mention by way of a law prohibiting games held too close to the town meeting house in Pittsfield, Mass. in 1792.
But it was the Knickerbocker Base Ball Club of New York that constituted the first organized club to play a game that is recognizable as a direct ancestor of our modern sport. Although they began exercising and playing together in 1842, the team formally organized on September 23, 1845. As part of their official incorporation, the Knickerbockers established a list of 20 rules, which were as follows:
1ST. Members must strictly observe the time agreed upon for exercise, and be punctual in their attendance. 2ND. When assembled for exercise, the President, or in his absence, the Vice-President, shall appoint an Umpire, who shall keep the game in a book provided for that purpose, and note all violations of the By-Laws and Rules during the time of exercise. 3RD. The presiding officer shall designate two members as Captains, who shall retire and make the match to be played, observing at the same time that the players put opposite to each other should be as nearly equal as possible, the choice of sides to be then tossed for, and the first in hand to be decided in like manner. 4TH. The bases shall be from "home" to second base, forty-two paces; from first to third base, forty-two paces, equidistant. 5TH. No stump match shall be played on a regular day of exercise. 6TH. If there should not be a sufficient number of members of the Club present at the time agreed upon to commence exercise, gentlemen not members may be chosen in to make up the match, which shall not be broken up to take in members that may afterwards appear; but in all cases, members shall have the preference, when present, at the making of the match. 7TH. If members appear after the game is commenced, they may be chosen in if mutually agreed upon. 8TH. The game to consist of twenty-one counts, or aces; but at the conclusion an equal number of hands must be played. 9TH. The ball must be pitched, not thrown, for the bat. 10TH. A ball knocked out of the field, or outside the range of the first and third base, is foul. 11TH. Three balls being struck at and missed and the last one caught, is a hand-out; if not caught is considered fair, and the striker bound to run. 12TH. If a ball be struck, or tipped, and caught, either flying or on the first bound, it is a hand out. 13TH. A player running the bases shall be out, if the ball is in the hands of an adversary on the base, or the runner is touched with it before he makes base; it being understood, however, that in no instance is a ball to be thrown at him. 14TH. A player running who shall prevent an adversary from catching or getting the ball before making his base, is a hand out. 15TH. Three hands out, all out. 16TH. Players must take their strike in regular turn. 17TH. All disputes and differences relative to the game, to be decided by the Umpire, from which there is no appeal. 18TH. No ace or base can be made on a foul strike. 19TH. A runner cannot be put out in making one base, when a balk is made by the pitcher. 20TH. But one base allowed when a ball bounds out of the field when struck.