
658 A.2d 1081 (1995)
COMMERCIAL UNION INSURANCE COMPANY
v.
ROYAL INSURANCE COMPANY.
Supreme Judicial Court of Maine.
Argued March 28, 1995.
Decided May 26, 1995.
Thomas F. Monaghan (orally), Monaghan, Leahy, Hochadel & Libby, Portland, for plaintiff.
James D. Poliquin (orally), Norman, Hanson & DeTroy, Portland, for defendant.
Before WATHEN, C.J., and ROBERTS, GLASSMAN, CLIFFORD, RUDMAN, DANA, and LIPEZ, JJ.
WATHEN, Chief Justice.
Defendant, Royal Insurance Company, appeals from a summary judgment entered in the Superior Court (Cumberland County, Brodrick, J.) holding Royal liable for a share of the defense costs incurred by plaintiff, Commercial Union Insurance Company, in defending the insureds, Francis Downey and Fill-it-Up Please, Inc. Commercial Union cross appeals from the court's apportionment of the defense costs. Finding no error, we affirm the judgment.
*1082 In 1990, Elliott Speers brought an action against Francis Downey and Fill-it-Up Please, Inc. The complaint alleged that during 1988, Downey and Fill-it-Up sold Speers a car wash system. The complaint included counts for the negligent design and installation of a car wash, and for negligent misrepresentation. In both counts, Speers alleged emotional distress as an element of damage. The complaint, however, did not specify when Speers suffered the emotional distress.
Royal provided insurance coverage to Downey and Fill-it-Up from April 8, 1987 to May 8, 1988 under a commercial general liability policy.[1] Downey notified Royal of Speers' lawsuit when it was commenced in 1990. In 1992, Royal informed Downey by letter that it had no duty to defend or indemnify him. Royal based its decision on information establishing that Speers did not open his car wash business until September 1989, more than a year after the termination of Downey's insurance contract with Royal.[2] Royal assumed that Speers' emotional distress could not have occurred prior to the opening of his car wash.
Commercial Union, Downey and Fill-it-Up's insurer under a commercial general liability policy from May 8, 1988 to May 1990, defended the action and incurred defense fees and costs. Commercial Union brought the present action for a declaratory judgment against Royal seeking reimbursement. Royal and Commercial Union both moved for a summary judgment. The Superior Court, relying on the "pleading comparison test," granted a summary judgment to Commercial Union and found that Royal had a duty to defend. After a trial on stipulated facts, the court apportioned the defense costs, and entered a judgment for Commercial Union for one-half of the $103,223.54 fees and costs.

I.
Royal argues that the court erred in granting a summary judgment to Commercial Union. It urges us to find that exclusive use of the comparison test in determining an insurer's duty to defend is inappropriate when an uncontroverted fact outside of the complaint establishes that the claim for damages falls outside the coverage period.
Summary judgment is proper "if the pleadings, depositions, answers to interrogatories, and admissions on file, together with the affidavits, if any, ... show that there is no genuine issue as to any material fact set forth in those statements and that any party is entitled to a judgment as a matter of law." M.R.Civ.P. 56(c). On appeal, we view the evidence in the light most favorable to the party against whom judgment was rendered, and review the court's decision for error of law. Worcester Ins. Co. v. Dairyland Ins. Co., 555 A.2d 1050, 1052 (Me.1989).
The question whether an insurer has a duty to defend in a particular case is a question of law. Baywood Corp. v. Maine Bonding & Casualty Co., 628 A.2d 1029, 1030 (Me.1993). We use a comparison test to assess an insurer's duty to defend. State Mut. Ins. Co. v. Bragg, 589 A.2d 35, 36 (Me.1991). Under that test, a court compares the allegations in the underlying complaint with the provisions of the insurance policy. Id. The insured is entitled to a defense if there is any legal or factual basis that could obligate an insurer to indemnify. Baywood, 628 A.2d at 1030; State Mut. Ins., 589 A.2d at 36. The complaint must show only a potential that the facts ultimately proved could come within coverage. Travelers Indem. Co. v. Dingwell, 414 A.2d 220, 226 (Me.1980).
Royal argues that an exception to the comparison test should be made when uncontroverted facts extrinsic to the complaint establish that the claim for damages falls outside the coverage period provided by the *1083 insurance policy. The facts in this case, however, do not support the exception Royal asks us to create. Contrary to Royal's contentions, the date of operation of the car wash is not determinative. Emotional distress could have resulted from negligent misrepresentation before the car wash opened for business.
In this case, we are not persuaded of the need to create an exception to the pleading comparison test. The duty to defend is broader than the duty to indemnify, and an insurer may have to defend before it is clear whether there is a duty to indemnify. State Mut. Ins., 589 A.2d at 36. Extrinsic facts known to the insurer may properly form the basis for a declaratory judgment action. Worcester, 555 A.2d at 1053. The Superior Court correctly ruled that Royal had a duty to defend.

II.
Based on stipulated facts as to the total defense costs, the Superior Court held Royal liable for one-half of the costs incurred by Commercial Union in defending the lawsuit filed against Downey and Fill-it-Up Please. On cross appeal, Commercial Union argues that the court's apportionment of defense costs was inequitable. We review for error or abuse of discretion, Globe Indemnity Co. v. Jordan, 634 A.2d 1279, 1284 (Me.1993), and find none.
The entry is:
Judgment affirmed.
All concurring.
NOTES
[1]  The policy provided, in part, that Royal would pay "all sums which the insured shall become legally obligated to pay as damages because of... bodily injury ... to which this insurance applies, caused by an occurrence...." An occurrence is defined as "an accident, including continuous or repeated exposure to conditions, which results in bodily injury or property damages neither expected nor intended from the standpoint of the insured."
[2]  Downey filed an affidavit in the underlying case in August 1991 stating that the car wash opened in September 1989.
