The Swiss-made Solar Impulse took off from Quarzazate in southern Morocco at 07:33, and touched down in the Moroccan capital at 23:20 (GMT), to applause from the Solar Impulse team and Moroccan officials.
"Magnificent, very nice flight" said Swiss pilot Andre Borschberg as he climbed down from the aircraft.
Borschberg had landed in Ouarzazate, about 550km from Rabat, on 22 June after having to abandon an attempt a week earlier because of strong winds and turbulence near the Atlas mountains.
That was the final stage of a trip that has taken him from his native Switzerland to Spain and then to Morocco.
The giant high-tech aircraft, which has the wingspan of a jumbo jet but weighs no more than a medium-sized car, is fitted with 12 000 solar cells feeding four electric motors driving propellers.
Last month, the solar-powered aircraft made the 2 500km journey from Madrid to Rabat, its longest to date and its first between continents, after an inaugural flight to Paris and Brussels last year.
The aircraft's next journey is set to be a return to its departure point Switzerland via Madrid. The exact date is not known.
The flights are intended as a rehearsal for the goal of a round-the-world trip in 2014 by an updated version of the aircraft.