They are valid but not interchangeable. I think the most important difference is that "in the beginning" seems to be an expression describing a whole period of time, while "at the beginning" more literally describes a single moment in time, similar to the difference between saying "in the morning" and "at 8 a.m." More @Wikipedia
Hover over any link to get a description of the article. Please note that search keywords are sometimes hidden within the full article and don't appear in the description or title.