Ah... Transformers! A classic Japanese anime and toy series.
Wait, Japanese anime and toy series? Transformers?!

Well, yeah. Okay, technically they aren't anime, or Japanese. Or are they? The Transformers television episodes were directed and animated by several big-name Japanese animation companies (such as Tokyo Movie Shinsha). The Transformers movie, an icon of near-religious reverence for people of my generation, had much more in common with anime of the period than with any American animated film (just look at the bits with Kranix and Arblus on Lithone, just before Unicron eats them), thanks to its largely-Japanese production staff. The Japanese involvement with the cool little transformable robots didn't end there, either, since transfans in the land of the Rising Sun were treated to whole animated epics about the Transformers, long after the show went off the air in America. Those new episodes, produced and animated in Japan for a wholly Japanese audience, ARE anime, which blurs the distinction between anime and The Transformers even more.
And I haven't even gotten to the good part yet.

What most people don't realize is that the Autobots and Decepticons were Japanese from the very beginning. They didn't originate with Hasbro in 1984, but instead were adapted from toys that Japanese kids had already been playing with for YEARS. And while the basic forms of these toys would be recognizable to American kids, the backstory for these versions was radically different from the epic war story between sentient robots from the planet Cybertron that we were treated to here in the States.
In the early-mid 80s, US toy giant Hasbro was looking for a new toy line. Giant robots were always popular (such as the Shogun Warriors line of the 70s), so Hasbro execs decided that a line of robot toys would sell well to American boys. And who knows giant robots best? The Japanese, of course. So off Hasbro trundled to Japan.
There, Hasbro got lucky. Japan at the time had warehouses crammed full of unsold toys from several different transforming robot lines. Best of all, the companies that made those toys were perfectly willing to sell their remaining stock to Hasbro. Hasbro then repackaged and relabeled these Japanese toys, came up with a backstory for them, and toy history was made.
This means that Optimus Prime and Megatron had lives BEFORE they began their epic battle for Earth and Cybertron. In fact, they weren't even from the same toy series in Japan! The initial Transformers releases, known as "Generation 1" today, came from several different Japanese toy lines.

By far the largest number of toys adapted into Transformers came from the toy line called Diaclone, released in Japan in 1980 by Takara. While these toys didn't have any cartoons or comics associated with them, they did have a rather extensive backstory. A race of vicious aliens, called the Warudars, attacks Earth, using a variety of insectlike transforming war machines. To stop them, Earth develops their own robot war machines, which can transform into regular Earth vehicles to help disguise them, and gives them to the brave young warriors of the Diaclone Taskforce . Why giant robots fighting alien invaders NEED to be undercover is, apparently, left unexplained. Unlike the Transformers, which were sentient robots, all the Diaclone machines were just piloted mecha. Each Diaclone toy thus came with a little pilot figure (with magnetic feet), and many of the toys had cockpit areas for these figures to fit into (in case you were wondering why your Optimus toy had a chest that opened up to reveal a little seat inside).
All the Diaclone Taskforce mecha were "good guys," and the toy line had very few "bad guy" Warudar mecha. Naturally, Hasbro needed to have TWO sides in their Transformers story (conflict being a requirement for boy's toys), and so they split the Diaclone robots into two opposing groups. The cars (which became Wheeljack, Sunstreaker, Ratchet, Ironhide, Skids, Trailbreaker, Bluestreak, Hoist, Inferno, Smokescreen, Hound, Prowl, Jazz, Sideswipe, Mirage, Grapple, and Tracks) became the heroic Autobots, while the jets (which became Starscream, Thundercracker, and Skywarp) became the Decepticons. The split wasn't even, however, and so other changes had to be made. The six construction vehicles that combined into a larger robot became the Constructicons, and joined the side of the Decepticons.
The Diaclone toys also gave the Transformers line their first Triple Changer (Blitzwing), the two Autobot Jumpstarters, and the ever-popular Dinobots (originally created to help the Diaclone Taskforce fight off an army of dinosaurs plucked from the past by the Warudars). Only three of the Warudar mecha were adapted for Transformers, becoming the original Insecticons.
Lastly, the Autobot leader, the great Optimus Prime, was taken from the Diaclone series (as well as the Optimus spinoff toy Ultra Magnus). In the original Diaclone, this mecha's name was Convoy, and the name survives today in the Japanese Transformers, where the Autobot with the personality and look of Optimus Prime is called Convoy to this day.
The Diaclone line also included about a dozen different types of Japanese railway cars that could transform into robots. Wisely, Hasbro passed on these!
Strangely, Diaclone toys were actually sold in the US before Hasbro bought the rights to use them in Transformers. The toys that later became Ironhide, Sunstreaker, and Trailbreaker were marketed in America under the Diakron name, and several others were sold as Kronoform toys.

Long time Transformers fans may note several rather large omissions from the rosters given above. This was because Hasbro grabbed toys from more than just the Diaclone line. Diaclone gave us most of the core Autobots, but very few Decepticons. The rest of the Decepticons, including the heavy hitters, came from the Microman toy series. Microman originated in 1974, and was also released by Takara. It revolved around miniature beings from the Microverse, coming to Earth to battle the evil Acroyears. Both sides built mecha to help them in their fight, disguised as Earth machines (at least THESE guys had a good reason for disguises). The Microman line mostly consisted of strange miniature humanoid figures, and their various battle accessories.
If all of this sounds a little familiar, there's a good reason for that. The initial 1974 line was actually licensed in the US as Micronauts, long before the Transformers concept. Those among us who grew up in the 70s may remember the intricate, customizable Micronaut toys, featuring the evil Baron Karza, the now-heroic Acroyear, and their accessories and mecha (like Biotron). Marvel Comics even published a long-running comic series based on the toys.
In 1981, the New Microman line replaced the venerable originals. As part of that new toy series, Takara introduced the Micro Change line. These were everyday-type objects that could transform into robots, and these robots could then be piloted by the miniature Micromen themselves. Soundwave the cassette player was adapted from this line, as were his transforming tapes Rumble, Ravage, Frenzy, Laserbeak, and Buzzsaw. There were also several guns that transformed into robots, such as a 1910 Browning, a .44 magnum revolver, and a Walther P-38. The last of these became Megatron, leader of the Decepticons.
Several minor Autobots were adapted from this line as well, such as Perceptor, the microscope, and the "mini-bots", like Cliffjumper, Windcharger, Huffer, Gears, Brawn, and the ever-popular Bumblebee.
This Microman line also was the genesis of the goofy "robot watches", digital watches that could transform into a little robot, that were popular in the US in the 80s. Hasbro did market these, but there were legions of other versions sold in the US as well.
With the recent Image release of a new Micronauts series. you can walk into a comic shop, buy a copy of "Micronauts", then walk into a toy store and buy a Transformers Energon Megatron toy... and both of those are descended from this single Japanese toy line of thirty years ago.
Like Diaclone, certain New Microman toys were also sold in the US before the Transformers license hit. They were combined with several of the Diaclone toys to form the Kronoform toy line. A lot of those annoying robot watch spinoffs came from Kronoform.

Minor series
As Transformers took off in popularity, Hasbro began manufacturing their own transforming toys rather than relying on repackaged Japanese toys. However, there were several later Transformers releases that DID come from the dusty warehouses of Japan. The Deluxe Insecticons, for example, were adapted from a toy line called Beetras, about the pilots of insectoid mecha from below the Earth's crust (aren't you glad we got the storyline we did?).
Anime fans may recognize the name of Shoji Kawamori. He was responsible for the story and fantastic mecha designs in such series as Macross and Vision of Escaflowne. At least three of his mecha designs for anime series found new life as Hasbro Transformers toys. The most famous is probably Jetfire, who was adapted from a standard Bandai Valkyrie toy from Macross. The Macross anime was in turn adapted into Robotech, another cartoon staple for children of the Transformers generation. The Jetfire toy is today highly sought after by collectors of both series, since there never was a Robotech Veritech (the US name for the Valkyrie) released, and the Jetfire toy was of an exceptionally high quality.
Kawamori was also mecha designer for a little-known 36-episode anime series called Dorvack (not to be confused with the kid from Welcome Back, Kotter). Dorvack never made it to American shores, but two of the toys based on Shoji Kawamori-designed mecha in that series DID. The Transformers known as Roadbuster and Whirl were taken from this series. At this point, though, Transformers became a wholly American concern. All the later toys (especially in Generation 2) were American-created, and the series eventually spun off into the Beast Wars and Beast Machines series. However, the Japanese (as I mentioned back at the start) wholeheartedly embraced the American adaptation of their old toy lines. Entirely unique Japanese TV series, movies, and toy lines were created based on the American Transformers. And the latest incarnations of the show, currently running on Cartoon Network, are produced and animated in Japan. Even though Hasbro has abandoned the original Japanese toys in the new Transformers releases, some part of the series will always be true to its Japanese roots.