A bill which allows the introduction of top-up tuition fees in Scottish universities and colleges has been approved by MSPs at Holyrood.
Top-up tuition fees will be introduced in England
However, the fees will only be used to prevent medical courses being swamped by students from England when variable fees are brought in there next year.
The Scottish Executive said it was opposed to top-up fees in principle.
And it accepted a Lib Dem amendment which will make any extension of top-up fees subject to consultation.
From autumn 2006 annual tuition fees at universities in England - currently a flat rate of £1,150 - will vary from nothing up to a maximum of £3,000 depending on the institution.
Scottish ministers have always insisted that the Further and Higher Education (Scotland) Bill would not open the door to these English-style top-up fees.
But opponents were concerned that raising tuition fees for one subject could provide cover for introducing them across the board.
Powers in the bill allow ministers, with the approval of parliament, to set higher fee levels in order to protect the interests of Scottish students.
In subjects where there is particularly high demand, the bill also gives ministers powers, again with the approval of parliament, to set a different fee level for certain subjects.
Research has shown that about 35% of graduates from Scotland's five medical schools immediately leave Scotland to work, mostly in England, while around half of recruits to Scottish medical faculties are English.
The executive is concerned that the top-up fees, which could amount to £15,000 for a five-year medical course, could see an influx of English students to Scotland in search of cheaper courses.
The executive said it wants to protect places for Scottish students.
The Scottish National Party failed to push through an amendment to the bill which would have ruled out variable fees by course, so they could not be extended to dentistry and engineering courses.
Alex Neil MSP said that unless the SNP amendment was accepted, future ministers would have carte blanche to introduce variable fees at any institution and for any subject.
Tory MSP Murdo Fraser remarked on the "predicament" of Jim Wallace, a Liberal Democrat MSP who is minister for lifelong learning in the coalition executive.
Mr Fraser said: "The irony is that we have Liberal Democrats campaigning on a UK basis as the students' friend - and here we have the Liberal Democrat minister proposing to take powers to charge top-up fees.
"The Scottish Conservatives' position is quite clear - we oppose all top-up fees, north and south of the border."
The Greens also slammed the Liberal Democrats who they said had made much of their opposition to tuition fees, yet were refusing to rule out their future introduction.
Chris Ballance MSP said: "The executive, in particular Lib Dem minister Jim Wallace, claims to be against top up fees at the moment, but is proposing legislation that will enable ministers to introduce them in the future.
"We are calling on parliament, including the Liberal Democrats - to make a clear, principled stand and defeat this clause."
MSPs unanimously backed Liberal Democrat MSP Mike Pringle's plan to ensure ministers must conduct a 60-day consultation on any fee-raising plans, allow specific input from the National Union of Students and a full parliamentary vote.
The bill will also merge Scotland's higher and further education funding bodies, allowing investment to top £1.6bn by 2007-8, the executive said.
It will also allow ministers to fix a fee of up to £2,000 for students from England attending Scottish universities.