Fugitive American financier Robert Vesco flew into Costa Rica from neighboring Nicaragua yesterday seeking emergency medical treatment, but the government refused him entry and he returned to Managua, according to Costa Rican and U.S. spokesmen.

The 46-year-old millionaire landed in a chartered plane on an airstrip at Liberia, a small town about 30 miles from the Nicaraguan border, a Costa Rican government spokesman said. He stayed three hours while the Cabinet's Council of National Security met and voted against admitting him, the official said. A spokesman at the U.S. Embassy in San Jose, the Costa Rican capital, also said that Vesco had been denied entry and had returned to Nicaragua.

Vesco, who lived in Costa Rica for six years before fleeing in 1978 under threat of arrest and extradition to the United States, remains a controversial figure in the Central American country's political life. Costa Rica's new president, Luis Alberto Monge, announced before taking office Saturday that under his administration Vesco would be arrested and extradited to stand trial if he ever entered the country again. By refusing to let Vesco pass through customs, Monge's government avoided the issue.

The U.S. government has been chasing Vesco since 1971 to press charges that he looted $224 million from the Geneva-based mutual fund Investors Overseas Services. Vesco is also wanted for allegedly making an illegal $200,000 contribution to former president Richard Nixon's 1972 reelection campaign in hope of having the charges dropped.

Vesco's whereabouts had been uncertain for the past few months as he apparently traveled around the Caribbean seeking a secure refuge. He reportedly spent time in the Turks and Caicos, a British island territory south of the Bahamas; in Antigua; Costa Rica and Nicaragua before trying to return to Costa Rica yesterday.

Vesco originally was expelled from Costa Rica four years ago because of controversy about his alleged large business investments in the country and close ties to the nation's political leaders. He was close to aging national hero and former president Jose Figueres, who is credited with being the father of Costa Rican democracy. Vesco then moved to the Bahamas but eventually was ordered deported and left last July, according to his lawyer.

In Washington yesterday, State Department spokesman Joseph Reap said the United States had expressed its continuing interest in Vesco to Costa Rica "immediately after we found out" that he had arrived in the country. There was no official U.S. comment on the Costa Rican government's decision that effectively let the fugitive slip away.

The Nicaraguan government did not have an immediate comment on the reports that Vesco had flown from that country and then returned there yesterday. Foreign Minister Miguel D'Escoto said shortly after his return to Managua from abroad yesterday that he knew nothing about Vesco's whereabouts.

The spokesman for the U.S. Embassy in San Jose said it learned that Vesco had gone to Managua on May 3 and notified Washington and the embassy in Managua but obtained no confirmation from the Nicaraguan government.

Costa Rican officials said they believed that former president Figueres had appealed to Nicaragua's Sandinista government to allow Vesco a temporary haven in Nicaragua.

Figueres has had close ties with the Sandinistas since supporting their 1979 overthrow of the Somoza dictatorship in Nicaragua. The Costa Rican spokesman said that Figueres entertained Vesco on his farm outside San Jose earlier this month, although it was not clear whether the San Jose government, then headed by outgoing president Rodrigo Carazo, had authorized Vesco's entry.

Since the reported meeting with Vesco, Figueres has asked President Monge to help Vesco legally return to Costa Rica, the spokesman said. Monge visited Figueres Tuesday in a San Jose hospital that Figueres had entered for a heart operation, and Figueres handed him a letter signed by two Costa Rican doctors saying that Vesco was "seriously ill" with a urinary tract infection, according to the spokesman's account.

The letter, signed by Dr. Luis Burstein and Jaime Gutierrez, said Vesco urgently needed an operation and should be allowed to enter Costa Rica for "humanitarian" reasons, the official said. According to unconfirmed reports circulating in Costa Rica, Vesco recently has lost as much as 80 pounds.

When Vesco flew into Liberia yesterday at about 9 a.m., however, the four-minister Council of National Security voted to keep him out. The full Cabinet, meeting for the first time under Monge's direction, voted unanimously soon afterward to uphold the council's decision, according to the spokesman. The government said it would help the doctors visit Vesco in Nicaragua to treat him.

Reports began to surface about a month ago that Vesco had gone to Costa Rica from the Caribbean island-nation of Antigua. On learning of these reports, the U.S. State Department asked the Costa Rican government to help it locate Vesco and, if possible, extradite him, Reap said.