Where was chess invented in?

H. J. R. Murray's chess history
https://web.archive.org/web/20140708090911/http://www.chesscafe.com/text/review883.pdf

The predecessor of chess, Chaturanga, was invented in India. Stalemate being a draw was probably introduced in Italy in the 13th century, but this rule didn't reach England until the 19th century. The mad queen game we play now probably was first proposed in Spain or Portugal in the 1470's. Modern castling rules probably arose in France around 1620.

The initial version of the game was invented in India.
It spread to Europe through Persia where "shah matia" - the king is helpless - became "checkmate" in English.
The current move rules were made in Paris in the early 1500's but certain other rules, like White always moving first, were not finalized until the late 1800's, again in Europe.
Since then, clock rules and various tournament behavior rules were modified throughout the past two centuries.

Some also think that the original Indian version may have been influenced by a game from China, though it is also possible the influence went the other way.
It is also possible that all those games were influenced by an even earlier game and developed independently as variations/evolutions of that game.

At the first U.S. Chess Congress in 1857 (won by Morphy ahead of Paulsen), Lowenthal apparently recommended that White move first saying that this was the practice in London chess clubs. The tournament at New York 1880 required that White move first. At London 1883, the player moving first had choice of colour. By 1889, the world champion Steinitz wrote that White moved first.

It seems the earliest description of a game that clearly resembles chess in Chinese is in 玄怪錄 Xuanguai lu 'Tales of the obscure and peculiar' written by 牛僧孺 Niu Sengru (779-847). In India, it would appear to be the Kavyalankara by Rudrat also in the 9th century. In Arabic, Al-Adli (800-870)'s Kitab ash-shatranj also describes the rules, but the arabs wrote that chess came from India via Persia.
Before that time, there were many board games often involving dice, similar to backgammon or pachisi. There were also older objects that could be chess pieces or 8x8 game boards, and older references to games with the names 'chaturanga' or 'xiangqi' for which we do not know the rules.
Here is a page on the origins of Chinese Chess:
http://www.banaschak.net/schach/origins.htm
The Chinese abstract strategy game Go dates from the 4th century B.C., and the ancient Greeks played a checkers-like game called Petteia.