"With God's help Nicaragua will not have any more fuel problems," Chavez said during a meeting with Ortega, who won the presidential election in November after nearly 17 years in opposition.
Ortega led the Sandinista revolution in 1979 and remained in power until voters threw him out in 1990.
Chavez gas pledge
Chavez also said that gas from a pipeline being built between Venezuela and Colombia and which he plans to expand to Panama, should also be available to Nicaragua.
Nicaragua, one of Latin America's poorest countries, generates 80 percent of its electricity from oil-derived fuel, and high world oil prices have caused an energy crisis that frequently blacks out large parts of the country.
he refinery project is one of a string of deals Chavez has made with friendly nations across Latin America and the Caribbean to counter US influence in the region.
Ortega's balancing act
Chavez said the refinery would be majority-owned by the Nicaraguan government, with Venezuela a minority owner.
He said that after Nicaragua had refined enough oil to satisfy internal demand, it could export the fuel elsewhere for cash, weaning itself off International Monetary Fund loans.
Ortega says he wants to maintain good relations with Washington while working closely with Chavez.
A day after confirming Nicaragua would stay in a Central America-wide free trade agreement it recently joined with the United States, Ortega announced he was also joining ALBA, Chavez's alternative accord grouping leftist allies like Cuba.