Caesar left Rome for Hispania in the spring of 49 BC, to secure the province and to defeat Pompey's 7 legions that were under the command of Marcus Petreius, Lucius Afranius, and Marcus Varro. Marching around the coast of Narbonensis, however, Caesar was stopped at the city of Massilia, where the well fortified town had been bribed into supporting Pompey. Caesar arrived on April 19 with 3 legions and immediately began to besiege the city, but he didn't dare risk being delayed and allow the Spanish legions to either come to the defense or be transferred to Pompey in Greece. He ordered Gaius Fabius to continue on to the Pyrenees to secure the northern passes with 3 other legions and focused on the siege.
The siege itself would turn into a long affair with mixed results. In all, it would end up taking 6 long months before the town would finally capitulate in October. By July though, Caesar couldn't afford to waste more time commanding an idle siege and had to move on to Hispania, where Fabius was under heavy pressure from Petreius and Afranius. Caesar left Decimus Brutus in command of the small naval force at Massilia and Gaius Trebonius was left to conduct the siege.
Caesar arrived in Hispania and took command from a likely very relieved Fabius. Caesar's men had suffered heavy casualties but managed to hold their positions and fend off attacks. No longer needing to hold the mountain passes, Caesar moved to Ilerda, where he began the systematic outmaneuvering and besieging of the opposition army. Initially, Pompey's lieutenants did a fine job in defense against Caesar's attacks, but as always, the war of attrition, Caesar's exceptional skill and his famous luck began to win out. Many of the more powerful tribes in the region preferred Caesar as well, bringing the Oscenses Calagurritani, Tarraconenses, Jacetani, Ausetani and Illurgavonenses to his side. With the support of the native cavalry, Caesar had the ability to encircle, cut off and outflank the enemy at every turn.
Sporadic and skirmish style fighting ensued, forcing Petreius and Afranius to retreat further into Hispania, while constantly seeking a position to fight on favorable terms. Caesar forced them towards the Ebro River and in late July finally had them starved and scared enough to gain the advantage. Caesar, the master of the siege, hemmed in the enemy with fortifications and forced Afranius and Petreius to seek a meeting. In a public display, in audible range of the men on both sides, Caesar accepted the surrender of Pompey's lieutenants and all the men under their command. 5 legions, which were grateful for not having to fight any meaningful battle against Caesar's troops, were disbanded and allowed to return to their homes and colonies within a few days.
Caesar's attention was next focused on his old friend Marcus Varro, in command of 2 legions in further Hispania. While Varro tried to be loyal to Pompey, as the honorable thing to do, both the locals and his own men preferred Caesar. Without even facing the enemy, 1 of Varro's legions mutinied at Cadiz in Caesar's favor, and any attempt to escape with an intact army was lost. Unable to defend and unable to take the remaining men to Greece, Varro sent word to Caesar in Corduba that he would surrender. In mid August, Varro did just that. In just about 40 days, Caesar had captured and eliminated the threat from Pompey's 'Spanish' legions with barely a fight. He spent some time organizing the administration of 'Spain' and meeting with local officials before heading out, but didn't stay long. His legate Cassius was left in command of Spain with 4 legions and he made haste to Massilia where good news was beginning to arrive. In early October, Caesar arrived at the besieged town to find that it had finally surrendered, though its commander Domitius had escaped. As punishment, he stripped the rights of the residents but spared the town from further destruction, beyond what it had suffered in the 6 month siege.
Back in Rome, the praetor Marcus Lepidus nominated Caesar to be dictator, and his puppet Senate quickly confirmed. Word of this news arrived to Caesar in Massilia, and he left for Rome shortly thereafter. In Rome, his first order of business, as it was getting late in the year, was to oversee the elections for 48 BC. Not surprisingly, he was elected Consul, along with the son of his former commander, Publius Servilius Isauricus. By now, Caesar certainly was aware of the disaster in Africa by his legate Curio. In late summer, Curio invaded Africa with 2 of his 4 legions, against the Republican Cato who was allied with the Numidian King Juba. Curio was terribly outnumbered and fought a hopeless battle in which he was killed on August 24, 49 BC. Certainly this news played a part in Calpurnius Piso, Caesar's father-in-law, along with other remaining Senators to convince Caesar to end the war.
Settling with Pompey now, might still bring a favorable settlement to all factions and prevent further bloodshed, but Isauricus convinced Caesar that there would never be peace until Pompey was beaten in the field. The dictator agreed and spent a few days settling things in Rome, such as granting citizenship to his allies in Cisalpine Gaul and restoring families who had been banished under Sulla, years before. (Caesar not only needed the support of anyone he could get, but desperately needed to rebuild the Senate ranks.) Taking care of these matters, Caesar resigned the dictatorship after only 11 days, gathered his men (12 legions in total) and began the march to Brundisium where he hoped to secure passage to Greece, and the Republican resistance.